DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.
Enter additional information related to this 'class' inside the {div} macro with 'id=description'
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
createNewColumn(columnName, type, length)
Creates a new column in this table.
createNewColumn(columnName, type, length, allowNull)
Creates a new column in this table.
createNewColumn(columnName, type, length, allowNull, pkColumn)
Creates a new column in this table.
void
deleteColumn(columnName)
Deletes the column with the specified name from this table.
String[]
getColumnNames()
Returns an array containing the names of all table columns.
getDataSource()
Returns the table data source uri.
getQuotedSQLName()
Returns a quoted version of the table name, if necessary, as defined by the actual database used.
String[]
getRowIdentifierColumnNames()
Returns an array containing the names of the identifier (PK) column(s).
getServerName()
Returns the Servoy server name.
isMetadataTable()
Returns whether table was flagged as metadata table.
{column:width=100%|padding=0px}{column}
Method Details
createNewColumn
(columnName, type, length)
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.createNewTable("users"); if (table) { var pk = table.createNewColumn("id", JSColumn.MEDIA, 16); // can also use (JSColumn.TEXT, 36) for UUIDs pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.setFlag(JSColumn.UUID_COLUMN, true) pk.sequenceType = JSColumn.UUID_GENERATOR var c = table.createNewColumn("name", JSColumn.TEXT, 100); c.allowNull = false table.createNewColumn("age", JSColumn.INTEGER, 0); table.createNewColumn("last_login", JSColumn.DATETIME, 0); var result = server.synchronizeWithDB(table); if (result) application.output("Table successfully created."); else application.output("Table not created."); } }
createNewColumn
(columnName, type, length, allowNull)
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.createNewTable("users"); if (table) { var pk = table.createNewColumn("id", JSColumn.MEDIA, 16); // can also use (JSColumn.TEXT, 36) for UUIDs pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.setFlag(JSColumn.UUID_COLUMN, true) pk.sequenceType = JSColumn.UUID_GENERATOR var c = table.createNewColumn("name", JSColumn.TEXT, 100); c.allowNull = false table.createNewColumn("age", JSColumn.INTEGER, 0); table.createNewColumn("last_login", JSColumn.DATETIME, 0); var result = server.synchronizeWithDB(table); if (result) application.output("Table successfully created."); else application.output("Table not created."); } }
createNewColumn
(columnName, type, length, allowNull, pkColumn)
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.createNewTable("users"); if (table) { var pk = table.createNewColumn("id", JSColumn.MEDIA, 16); // can also use (JSColumn.TEXT, 36) for UUIDs pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.setFlag(JSColumn.UUID_COLUMN, true) pk.sequenceType = JSColumn.UUID_GENERATOR var c = table.createNewColumn("name", JSColumn.TEXT, 100); c.allowNull = false table.createNewColumn("age", JSColumn.INTEGER, 0); table.createNewColumn("last_login", JSColumn.DATETIME, 0); var result = server.synchronizeWithDB(table); if (result) application.output("Table successfully created."); else application.output("Table not created."); } }
void
deleteColumn
(columnName)
Returns
void
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.getTable("users"); if (table) { table.deleteColumn("last_login"); server.synchronizeWithDB(table); } }
getColumn
(name)
Parameters
{String} name – The name of the column to return the value from.
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var jsColumn = jsTable.getColumn('campaign_name')
String[]
getColumnNames
()
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var columnNames = jsTable.getColumnNames()
getDataSource
()
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var dataSource = jsTable.getDataSource()
getQuotedSQLName
()
Sample
//use with the raw SQL plugin: //if the table name contains characters that are illegal in sql, the table name will be quoted var jsTable = databaseManager.getTable('udm', 'campaigns') var quotedTableName = jsTable.getQuotedSQLName() plugins.rawSQL.executeSQL('udm', quotedTableName, 'select * from ' + quotedTableName + ' where is_active = ?', [1])
String[]
getRowIdentifierColumnNames
()
Returns
String[] – String array of row identifier column names.
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var identifierColumnNames = jsTable.getRowIdentifierColumnNames()
getSQLName
()
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var tableNameForDisplay = jsTable.getSQLName()
getServerName
()
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var serverName = jsTable.getServerName()
isMetadataTable
()
Sample
var jsTable = databaseManager.getTable('udm', 'campaigns') var isMetaDataTable = jsTable.isMetadataTable()