{hidden}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden}
{sub-section:description|text=}{sub-section}\\
{table:id=|class=servoy sSummery}{colgroup}{column:padding=0px|width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summery{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:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=createNewTable|class=node}{tr:id=name}{td}h6.createNewTable{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSTableObject]{span}{span:id=iets|style=float: left; font-weight: bold;}createNewTable{span}{span:id=iets|style=float: left;}\(tableName){span}{td}{tr}{tr:id=des}{td}{sub-section:createNewTable_des|text=|trigger=button}{sub-section}{sub-section:createNewTable_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:createNewTable_snc|text=|trigger=button}{sub-section}{sub-section:createNewTable_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:createNewTable_prs|text=|trigger=button}{sub-section}{sub-section:createNewTable_prs|trigger=none|class=sIndent}\{[String]} tableName -- The name of the table to create.
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:createNewTable_ret|text=|trigger=button}{sub-section}{sub-section:createNewTable_ret|trigger=none|class=sIndent}[JSTableObject] -- JSTableObject created table.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:createNewTable_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createNewTable_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:createNewTable_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createNewTable_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:createNewTable_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:createNewTable_sam|trigger=none}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server)
{
var table = server.createNewTable("new_table");
if (table) {
table.createNewColumn("new_table_id", JSColumn.INTEGER, 0, false, true);
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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=dropTable|class=node}{tr:id=name}{td}h6.dropTable{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}dropTable{span}{span:id=iets|style=float: left;}\(tableName){span}{td}{tr}{tr:id=des}{td}{sub-section:dropTable_des|text=|trigger=button}{sub-section}{sub-section:dropTable_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:dropTable_snc|text=|trigger=button}{sub-section}{sub-section:dropTable_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:dropTable_prs|text=|trigger=button}{sub-section}{sub-section:dropTable_prs|trigger=none|class=sIndent}\{[String]} tableName -- The name of the table to drop.
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:dropTable_ret|text=|trigger=button}{sub-section}{sub-section:dropTable_ret|trigger=none|class=sIndent}[Boolean] -- boolean success.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:dropTable_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:dropTable_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:dropTable_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:dropTable_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:dropTable_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:dropTable_sam|trigger=none}{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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getTable|class=node}{tr:id=name}{td}h6.getTable{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSTableObject]{span}{span:id=iets|style=float: left; font-weight: bold;}getTable{span}{span:id=iets|style=float: left;}\(tableName){span}{td}{tr}{tr:id=des}{td}{sub-section:getTable_des|text=|trigger=button}{sub-section}{sub-section:getTable_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getTable_snc|text=|trigger=button}{sub-section}{sub-section:getTable_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:getTable_prs|text=|trigger=button}{sub-section}{sub-section:getTable_prs|trigger=none|class=sIndent}\{[String]} tableName -- The name of the table to retrieve.
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:getTable_ret|text=|trigger=button}{sub-section}{sub-section:getTable_ret|trigger=none|class=sIndent}[JSTableObject] -- JSTableObject table.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getTable_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTable_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getTable_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTable_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getTable_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTable_sam|trigger=none}{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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getTableNames|class=node}{tr:id=name}{td}h6.getTableNames{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[String]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getTableNames{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:getTableNames_des|text=|trigger=button}{sub-section}{sub-section:getTableNames_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:getTableNames_snc|text=|trigger=button}{sub-section}{sub-section:getTableNames_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:getTableNames_prs|text=|trigger=button}{sub-section}{sub-section:getTableNames_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:getTableNames_ret|text=|trigger=button}{sub-section}{sub-section:getTableNames_ret|trigger=none|class=sIndent}[String]\[] -- Array of String table names.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:getTableNames_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTableNames_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:getTableNames_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTableNames_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:getTableNames_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:getTableNames_sam|trigger=none}{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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=isValid|class=node}{tr:id=name}{td}h6.isValid{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}isValid{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:isValid_des|text=|trigger=button}{sub-section}{sub-section:isValid_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:isValid_snc|text=|trigger=button}{sub-section}{sub-section:isValid_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:isValid_prs|text=|trigger=button}{sub-section}{sub-section:isValid_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:isValid_ret|text=|trigger=button}{sub-section}{sub-section:isValid_ret|trigger=none|class=sIndent}[Boolean] -- boolean valid state.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:isValid_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:isValid_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:isValid_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:isValid_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:isValid_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:isValid_sam|trigger=none}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (!server.isValid()) {
application.output("Server not valid!");
}
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=reloadDataModel|class=node}{tr:id=name}{td}h6.reloadDataModel{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}reloadDataModel{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:reloadDataModel_des|text=|trigger=button}{sub-section}{sub-section:reloadDataModel_des|trigger=none|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().
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:reloadDataModel_snc|text=|trigger=button}{sub-section}{sub-section:reloadDataModel_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:reloadDataModel_prs|text=|trigger=button}{sub-section}{sub-section:reloadDataModel_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:reloadDataModel_ret|text=|trigger=button}{sub-section}{sub-section:reloadDataModel_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:reloadDataModel_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:reloadDataModel_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:reloadDataModel_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:reloadDataModel_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:reloadDataModel_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:reloadDataModel_sam|trigger=none}{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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=synchronizeWithDB|class=node}{tr:id=name}{td}h6.synchronizeWithDB{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}synchronizeWithDB{span}{span:id=iets|style=float: left;}\(table){span}{td}{tr}{tr:id=des}{td}{sub-section:synchronizeWithDB_des|text=|trigger=button}{sub-section}{sub-section:synchronizeWithDB_des|trigger=none|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.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:synchronizeWithDB_snc|text=|trigger=button}{sub-section}{sub-section:synchronizeWithDB_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:synchronizeWithDB_prs|text=|trigger=button}{sub-section}{sub-section:synchronizeWithDB_prs|trigger=none|class=sIndent}\{[JSTableObject]} table -- A JSTableObject instance that should be synchronized.
{sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:synchronizeWithDB_ret|text=|trigger=button}{sub-section}{sub-section:synchronizeWithDB_ret|trigger=none|class=sIndent}[Boolean] -- boolean success.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:synchronizeWithDB_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:synchronizeWithDB_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:synchronizeWithDB_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:synchronizeWithDB_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:synchronizeWithDB_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:synchronizeWithDB_sam|trigger=none}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server)
{
var table = server.createNewTable("new_table");
if (table) {
table.createNewColumn("new_table_id", JSColumn.INTEGER, 0, false, true);
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}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}prs
Parameters
sIndenttableA JSTableObject instance that should be synchronized.ret