{div:style=display:none}
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'{div}
{div:id=description}{div}\\
{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[JSTableObject]{td}{td}[#createNewTable]\(tableName)
Creates in this server a new table with the specified name.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#dropTable]\(tableName)
Drops the table with the specified name from this server.{td}{tr}{tbody}{tbody}{tr}{td}[JSTableObject]{td}{td}[#getTable]\(tableName)
Returns a JSTable instance corresponding to the table with the specified name from this server.{td}{tr}{tbody}{tbody}{tr}{td}[String]\[]{td}{td}[#getTableNames]\()
Returns an array with the names of all tables in this server.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#isValid]\()
Get valid state for the server.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#reloadDataModel]\()
Reloads the datamodel from the database, if changed externally or via rawSQL plugin.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#synchronizeWithDB]\(table)
Synchronizes a JSTable instance with the database.{td}{tr}{tbody}{table}\\
{table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=createNewTable-String}{tr:id=name}{td}h6.createNewTable{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSTableObject]{span}{span:style=font-weight: bold;}createNewTable{span}{span}\(tableName){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}
Cache
index
true
refresh
100d
showRefresh
true
id
doc
title
Refresh page
showDate
true
retry
Enable
servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClientservoy sSummary12%30%58%height: 30px;3Methods SummaryCreates in this server a new table with the specified name.Drops the table with the specified name from this server.Returns a JSTable instance corresponding to the table with the specified name from this server.Returns an array with the names of all tables in this server.Get valid state for the server.voidReloads the datamodel from the database, if changed externally or via rawSQL plugin.Synchronizes a JSTable instance with the database.functionservoy sDetail2100%height:30px2Methods DetailscreateNewTablename
createNewTable(tableName)
dessIndent
Creates in this server a new table with the specified name.
{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} tableName -- The name of the table to create.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSTableObject] -- JSTableObject created table.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server)
{
var table = server.createNewTable("new_table");
if (table) {
var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0);
pk.rowIdentifierType = JSColumn.PK_COLUMN;
if (server.synchronizeWithDB(table))
application.output("New table created in the database.");
else
application.output("New table not created in database.");
}
else application.output("New table not created at all.");
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=dropTable-String}{tr:id=name}{td}h6.dropTable{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}dropTable{span}{span}\(tableName){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}prs
Parameters
sIndenttableNameThe name of the table to create.ret
Returns
sIndent JSTableObject created table.clients
Supported Clients
sIndentSmartClient,WebClient,NGClientsam
Sample
sIdentjavascriptlastDetailRowdropTablename
dropTable(tableName)
dessIndent
Drops the table with the specified name from this server.
{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} tableName -- The name of the table to drop.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- boolean success.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server) {
var result = server.dropTable("new_table");
if (result)
application.output("Table dropped.");
else
application.output("Table not dropped.");
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getTable-String}{tr:id=name}{td}h6.getTable{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSTableObject]{span}{span:style=font-weight: bold;}getTable{span}{span}\(tableName){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}prs
Parameters
sIndenttableNameThe name of the table to drop.ret
Returns
sIndent boolean success.clients
Supported Clients
sIndentSmartClient,WebClient,NGClientsam
Sample
sIdentjavascriptlastDetailRowgetTablename
getTable(tableName)
dessIndent
Returns a JSTable instance corresponding to the table with the specified name from this server.
{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} tableName -- The name of the table to retrieve.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSTableObject] -- JSTableObject table.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server) {
var table = server.getTable("employees");
if (table) {
var colNames = table.getColumnNames()
application.output("Table has " + colNames.length + " columns.");
for (var i=0; i<colNames.length; i++)
application.output("Column " + i + ": " + colNames[i]);
}
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getTableNames}{tr:id=name}{td}h6.getTableNames{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]\[]{span}{span:style=font-weight: bold;}getTableNames{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}prs
Parameters
sIndenttableNameThe name of the table to retrieve.ret
Returns
sIndent JSTableObject table.clients
Supported Clients
sIndentSmartClient,WebClient,NGClientsam
Sample
sIdentjavascriptlastDetailRowgetTableNamesname
getTableNames()
dessIndent
Returns an array with the names of all tables in this server.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]\[] -- Array of String table names.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server) {
var tableNames = server.getTableNames();
application.output("There are " + tableNames.length + " tables.");
for (var i=0; i<tableNames.length; i++)
application.output("Table " + i + ": " + tableNames[i]);
}
else {
plugins.dialogs.showInfoDialog("Attention","Server 'example_data' cannot be found.","OK");
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=isValid}{tr:id=name}{td}h6.isValid{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}isValid{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}ret
Returns
sIndent Array of String table names.clients
Supported Clients
sIndentSmartClient,WebClient,NGClientsam
Sample
sIdentjavascriptlastDetailRowisValidname
isValid()
dessIndent
Get valid state for the server.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- boolean valid state.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (!server.isValid()) {
application.output("Server not valid!");
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=reloadDataModel}{tr:id=name}{td}h6.reloadDataModel{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}reloadDataModel{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}ret
Returns
sIndent boolean valid state.clients
Supported Clients
sIndentSmartClient,WebClient,NGClientsam
Sample
sIdentjavascriptlastDetailRowreloadDataModelname
reloadDataModel()
dessIndent
Reloads the datamodel from the database, if changed externally or via rawSQL plugin.
This call is not needed after a call to synchronizeWithDB().
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
var result = plugins.rawSQL.executeSQL("example_data", null, 'CREATE TABLE raw_table (raw_table_id INTEGER)');
if (result) {
application.output("Table created through rawSQL plugin.");
if (server) {
server.reloadDataModel();
// All existing JSTableObject/JSColumn object references are invalid now! Use getTable to get new ones.
var table = server.getTable("raw_table");
if (table) {
var colNames = table.getColumnNames()
application.output("Table has " + colNames.length + " columns.");
for (var i=0; i<colNames.length; i++)
application.output("Column " + i + ": " + colNames[i]);
}
}
}
else {
application.output("Raw table creation failed: " + plugins.rawSQL.getException());
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=synchronizeWithDB-JSTableObject}{tr:id=name}{td}h6.synchronizeWithDB{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}synchronizeWithDB{span}{span}\(table){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}clients
Synchronizes a JSTable instance with the database. If columns were added to or removed from the JSTable instance, all these changes will now be persisted to the database.
{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[JSTableObject]} table -- A JSTableObject instance that should be synchronized.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- boolean success.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server)
{
var table = server.createNewTable("new_table");
if (table) {
var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0);
pk.rowIdentifierType = JSColumn.PK_COLUMN;
if (server.synchronizeWithDB(table))
application.output("New table created in the database.");
else
application.output("New table not created in database.");
}
else application.output("New table not created at all.");
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}prs
Parameters
sIndenttableA JSTableObject instance that should be synchronized.ret