Child pages
  • Maintenance Mode
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »

Function

createNewTable

Description

Creates in this server a new table with the specified name.

Syntax
createNewTable(tableName)

Parameters
tableName -

Example

var server = plugins.maintenance.getServer("example_data");
if (server)
{
	var table = server.createNewTable("new_table");
	if (table) application.output("New table created.");
	else application.output("New table not created.");
}

Function

getTable

Description

Returns a JSTable instance corresponding the the table with the specified name from this server.

Syntax
getTable(tableName)

Parameters
tableName -

Example

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]);
	}
}

Function

synchronizeWithDB

Description

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.

Syntax
synchronizeWithDB(table)

Parameters
table -

Example

var server = plugins.maintenance.getServer("example_data");
if (server) {
	var table = server.getTable("new_table");
	if (table) {
		table.createNewColumn("new_column", DM_COLUMNTYPE.TEXT, 100);
var result = server.synchronizeWithDB(table);
		if (result)
			application.output("Table successfully synchronized.");
		else
			application.output("Table not synchronized.");
	}
}

Function

dropTable

Description

Drops the table with the specified name from this server.

Syntax
dropTable(tableName)

Parameters
tableName -

Example

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.");
}

Function

getTableNames

Description

Returns an array with the names of all tables in this server.

Example

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");
}

  • No labels