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
{column:width=80px|padding=0px}{column}{column}{column}
Constants Summary
DATABASE_IDENTITY
Constant used when setting or getting the sequence type of columns.
DATABASE_SEQUENCE
Constant used when setting or getting the sequence type of columns.
EXCLUDED_COLUMN
Constant used when setting or getting the flags of columns.
ROWID_COLUMN
Constant used when setting or getting the row identifier type of columns.
SERVOY_SEQUENCE
Constant used when setting or getting the sequence type of columns.
UUID_COLUMN
Constant used when setting or getting the flags of columns.
UUID_GENERATOR
Constant used when setting or getting the sequence type of columns.
{column:width=80px|padding=0px}{column}{column}{column}
Property Summary
rowIdentifierType
Get or set the row identifier type of the column.
sequenceType
Get or set the sequence type of the column.
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
getDataProviderID()
Get the data provider id for this column (which is the same as name if not explicitly defined otherwise).
getDescription()
Get the description property of the column.
getForeignType()
Get the foreign type of the column.
getQualifiedName()
Get the qualified name (including table name) of the column as known by the database.
getQuotedSQLName()
Returns a quoted version of the column name, if necessary, as defined by the actual database used.
getSQLName()
Get the name of the column as known by the database.
getTypeAsString()
Get the name JDBC type of the column.
void
setDatabaseSequenceName()
Set the database sequence name of the column, used for columns with sequence type JSColumn.
void
setFlag(flag, set)
Set or clear a flag of a new column.
{column:width=100%|padding=0px}{column}
Constants Details
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getSequenceType()) { case JSColumn.NONE: // handle column with no sequence break; case JSColumn.UUID_GENERATOR: // handle uuid generated column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getSequenceType()) { case JSColumn.NONE: // handle column with no sequence break; case JSColumn.UUID_GENERATOR: // handle uuid generated column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') if (column.hasFlag(JSColumn.UUID_COLUMN)) { // handle uuid column }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getSequenceType()) { case JSColumn.NONE: // handle column with no sequence break; case JSColumn.UUID_GENERATOR: // handle uuid generated column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getRowIdentifierType()) { case JSColumn.NONE: // handle normal column break; case JSColumn.PK_COLUMN: // handle database pk column break; case JSColumn.ROWID_COLUMN: // handle developer defined pk column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getRowIdentifierType()) { case JSColumn.NONE: // handle normal column break; case JSColumn.PK_COLUMN: // handle database pk column break; case JSColumn.ROWID_COLUMN: // handle developer defined pk column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getSequenceType()) { case JSColumn.NONE: // handle column with no sequence break; case JSColumn.UUID_GENERATOR: // handle uuid generated column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') if (column.hasFlag(JSColumn.UUID_COLUMN)) { // handle uuid column }
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getSequenceType()) { case JSColumn.NONE: // handle column with no sequence break; case JSColumn.UUID_GENERATOR: // handle uuid generated column break; }
{column:width=100%|padding=0px}{column}
Property Details
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."); } }
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { // users has uuid pk 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 table.createNewColumn("name", JSColumn.TEXT, 100); var result = server.synchronizeWithDB(table); if (result) application.output("Table users successfully created."); else application.output("Table users not created."); } // groups has database sequence pk table = server.createNewTable("groups"); if (table) { pk = table.createNewColumn("id", JSColumn.INTEGER, 0); pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.sequenceType = JSColumn.DATABASE_SEQUENCE pk.setDatabaseSequenceName('mygroupsequence') table.createNewColumn("name", JSColumn.TEXT, 100); result = server.synchronizeWithDB(table); if (result) application.output("Table groups successfully created."); else application.output("Table groups not created."); } }
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { // users has uuid pk 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 table.createNewColumn("name", JSColumn.TEXT, 100); var result = server.synchronizeWithDB(table); if (result) application.output("Table users successfully created."); else application.output("Table users not created."); } // groups has database sequence pk table = server.createNewTable("groups"); if (table) { pk = table.createNewColumn("id", JSColumn.INTEGER, 0); pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.sequenceType = JSColumn.DATABASE_SEQUENCE pk.setDatabaseSequenceName('mygroupsequence') table.createNewColumn("name", JSColumn.TEXT, 100); result = server.synchronizeWithDB(table); if (result) application.output("Table groups successfully created."); else application.output("Table groups not created."); } }
{column:width=100%|padding=0px}{column}
Method Details
getDataProviderID
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') var dataProviderId = column.getDataProviderID()
getDescription
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customername') var desc = column.getDescription()
getForeignType
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') var foreignType = column.getForeignType() if (foreignType != null) { var fkTable = databaseManager.getTable('example_data', foreignType) }
getLength
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customername') if (column.getLength() < 10) { // handle short column }
getQualifiedName
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') var qualifiedSqlName = column.getQualifiedName()
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() var jsColumn = jsTable.getColumn('active') var quotedColumnName = jsColumn.getQuotedSQLName() plugins.rawSQL.executeSQL('udm', quotedTableName, 'select * from ' + quotedTableName + ' where ' + quotedColumnName + ' = ?', [1])
getSQLName
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') var sqlName = column.getSQLName()
getScale
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customername') var scale = column.getScale()
getTitle
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customername') var title = column.getTitle()
getType
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') switch (column.getType()) { case JSColumn.TEXT: // handle text column break; case JSColumn.NUMBER: case JSColumn.INTEGER: // handle numerical column break; }
getTypeAsString
()
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') var typeName = column.getTypeAsString()
hasFlag
(flag)
Sample
var table = databaseManager.getTable('db:/example_data/orders') var column = table.getColumn('customerid') if (column.hasFlag(JSColumn.UUID_COLUMN)) { // handle uuid column }
void
setDatabaseSequenceName
()
Returns
void
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { // users has uuid pk 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 table.createNewColumn("name", JSColumn.TEXT, 100); var result = server.synchronizeWithDB(table); if (result) application.output("Table users successfully created."); else application.output("Table users not created."); } // groups has database sequence pk table = server.createNewTable("groups"); if (table) { pk = table.createNewColumn("id", JSColumn.INTEGER, 0); pk.rowIdentifierType = JSColumn.PK_COLUMN; pk.sequenceType = JSColumn.DATABASE_SEQUENCE pk.setDatabaseSequenceName('mygroupsequence') table.createNewColumn("name", JSColumn.TEXT, 100); result = server.synchronizeWithDB(table); if (result) application.output("Table groups successfully created."); else application.output("Table groups not created."); } }
void
setFlag
(flag, set)
Returns
void
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."); } }