Child pages
  • rawSQL

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

padding0px
width80px

...

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary

...

Table Cell (td)
Boolean

...

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'
Divcache
styleindexdisplay:none

...

iddescription

...

padding0px
width80px

...

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Server Property Summary

...

Table Cell (td)
servoy.rawSQL.allowClientCacheFlushes

...

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Methods SummaryExecute any SQL, returns true if successful.

...

Table Cell (td)
Boolean

...

Execute any SQL, returns true if successful.

...

Table Cell (td)
JSDataSet

...

Execute a stored procedure, return all created result sets.Execute a stored procedure.

...

Table Cell (td)
Boolean

...

Flush cached database data.

...

Table Cell (td)
ServoyException
If the result from a function was false, it will return the exception object.

...

Table Cell (td)
Boolean

...

Notify clients about changes in records, based on pk(s).

...

0px

HTML Table
idserverProperty
classservoy sDetail
Colgroup Tag
Column
padding
width100%
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Server Property Details
Table Body (tbody)
idservoy.rawSQL.allowClientCacheFlushes
Table Row (tr)
idname
Table Cell (td)
servoy.rawSQL.allowClientCacheFlushes
Table Row (tr)
classlastDetailRow
Table Cell (td)

...

...

function

...

servoy sDetail

...

padding0px
width100%

...

2100%height:30px

...

Table Head (th)
colspan1
Method Details

...

idexecuteSQL-String_String_String
Table Row (tr)
idname
Table Cell (td)
executeSQL
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
executeSQL
Span
(serverName, tableName, sql)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Execute any SQL, returns true if successful.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{String} serverName - the name of the server
{String} tableName - the name of the table
{String} sql - the sql query to execute
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var country = 'NL'
var done = plugins.rawSQL.executeSQL("example_data","employees","update employees set country = ?", [country])
if (done)
{
	//flush is required when changes are made in db
	plugins.rawSQL.flushAllClientsCache("example_data","employees")
}
else
{
	var msg = plugins.rawSQL.getException().getMessage(); //see exception node for more info about the exception obj
	plugins.dialogs.showErrorDialog('Error',  'SQL exception: '+msg,  'Ok')
}

// Note that when this function is used to create a new table in the database, this table will only be seen by
// the Servoy Application Server when the table name starts with 'temp_', otherwise a server restart is needed.

...

classlastDetailRow

...

idexecuteSQL-String_String_String_ObjectArray
Table Row (tr)
idname
Table Cell (td)
executeSQL
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
executeSQL
Span
(serverName, tableName, sql, sql_args)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Execute any SQL, returns true if successful.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{String} serverName - the name of the server
{String} tableName - the name of the table
{String} sql - the sql query to execute
{Object[]} sql_args - the arguments for the query
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var country = 'NL'
var done = plugins.rawSQL.executeSQL("example_data","employees","update employees set country = ?", [country])
if (done)
{
	//flush is required when changes are made in db
	plugins.rawSQL.flushAllClientsCache("example_data","employees")
}
else
{
	var msg = plugins.rawSQL.getException().getMessage(); //see exception node for more info about the exception obj
	plugins.dialogs.showErrorDialog('Error',  'SQL exception: '+msg,  'Ok')
}

// Note that when this function is used to create a new table in the database, this table will only be seen by
// the Servoy Application Server when the table name starts with 'temp_', otherwise a server restart is needed.

...

classlastDetailRow

...

idexecuteStoredProcedure-String_String_ObjectArray_NumberArray_Number
Table Row (tr)
idname
Table Cell (td)
executeStoredProcedure

...

idsig

...

Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
executeStoredProcedure

...

2Methods DetailsexecuteSQLname

executeSQL(serverName, sql)

dessIndent
Execute any SQL, returns true if successful.
prs

Parameters

sIndentserverNamethe name of the serversqlthe sql query to execute
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
executeSQLname

executeSQL(serverName, sql, sql_args)

dessIndent
Execute any SQL, returns true if successful.
prs

Parameters

sIndentserverNamethe name of the serversqlthe sql query to executesql_argsthe arguments for the query
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
executeStoredProcedurename

executeStoredProcedure(serverName, procedureDeclaration, arguments, maxNumberOfRowsToRetrieve)

dessIndent
Execute a stored procedure, return all created result sets.
prs

Parameters

sIndentserverName ;procedureDeclaration ;arguments ;maxNumberOfRowsToRetrieve ;
ret

Returns

sIndent the result sets created by the procedure.
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
executeStoredProcedurename

executeStoredProcedure(serverName, procedureDeclaration, arguments, inOutDirectionality, maxNumberOfRowsToRetrieve)

...

des

...

sIndent
Execute a stored procedure.

...

prs

...

Parameters

...

sIndent

...

Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
JSDataSet
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var maxReturnedRows = 10; //useful to limit number of rows
var procedure_declaration = '{?=calculate_interest_rate(?)}'
// define the direction, a 0 for input data, a 1 for output data
var typesArray = [1, 0];
// define the types and values, a value for input data, a sql-type for output data
var args = [java.sql.Types.NUMERIC, 3000]
// A dataset is returned, when no output-parameters defined, the last select-result in the procedure will be returned.
// When one or more output-parameters are defined, the dataset will contain 1 row with the output data.
var dataset = plugins.rawSQL.executeStoredProcedure(databaseManager.getDataSourceServerName(controller.getDataSource()), procedure_declaration, args, typesArray, maxReturnedRows);
var interest_rate = dataset.getValue(1, 1);

...

classlastDetailRow

...

idflushAllClientsCache-String_String
Table Row (tr)
idname
Table Cell (td)
flushAllClientsCache
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
flushAllClientsCache
Span
(serverName, tableName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Flush cached database data. Use with extreme care, its affecting the performance of clients!
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{String} serverName
{String} tableName
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var country = 'NL'
var done = plugins.rawSQL.executeSQL("example_data","employees","update employees set country = ?", [country])
if (done)
{
	//flush is required when changes are made in db
	plugins.rawSQL.flushAllClientsCache("example_data","employees")
}
else
{
	var msg = plugins.rawSQL.getException().getMessage(); //see exception node for more info about the exception obj
	plugins.dialogs.showErrorDialog('Error',  'SQL exception: '+msg,  'Ok')
}

// Note that when this function is used to create a new table in the database, this table will only be seen by
// the Servoy Application Server when the table name starts with 'temp_', otherwise a server restart is needed.

...

classlastDetailRow

...

idgetException
Table Row (tr)
idname
Table Cell (td)
getException
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
ServoyException
Span
stylefont-weight: bold;
getException
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
If the result from a function was false, it will return the exception object.
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
ServoyException
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var country = 'NL'
var done = plugins.rawSQL.executeSQL("example_data","employees","update employees set country = ?", [country])
if (done)
{
	//flush is required when changes are made in db
	plugins.rawSQL.flushAllClientsCache("example_data","employees")
}
else
{
	var msg = plugins.rawSQL.getException().getMessage(); //see exception node for more info about the exception obj
	plugins.dialogs.showErrorDialog('Error',  'SQL exception: '+msg,  'Ok')
}

// Note that when this function is used to create a new table in the database, this table will only be seen by
// the Servoy Application Server when the table name starts with 'temp_', otherwise a server restart is needed.

...

classlastDetailRow

...

idnotifyDataChange-String_String_JSDataSet_Number
Table Row (tr)
idname
Table Cell (td)
notifyDataChange

...

idsig

...

Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
notifyDataChange

...

serverName ;procedureDeclaration ;arguments ;inOutDirectionality ;maxNumberOfRowsToRetrieve ;ret

Returns

sIndent a dataset with output (in case of output data) or the last result set executed by the procedure.
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
flushAllClientsCachename

flushAllClientsCache(serverName, tableName)

dessIndent
Flush cached database data. Use with extreme care, its affecting the performance of clients!
prs

Parameters

sIndentserverName ;tableName ;
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getExceptionname

getException()

dessIndent
If the result from a function was false, it will return the exception object.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
notifyDataChangename

notifyDataChange(serverName, tableName, pksDataset, action)

...

...

des

...

sIndent
Notify clients about changes in records, based on pk(s). Use with extreme care, its affecting the performance of clients!

...

prs

...

Parameters

...

classlastDetailRow

...

sIndent

...

Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
/****************************************************************************
WARNING! You can cause data loss or serious data integrity compromises!
You should have a THOROUGH understanding of both SQL and your backend
database (and other interfaces that may use that backend) BEFORE YOU USE
ANY OF THESE COMMANDS.
You should also READ THE DOCUMENTATION BEFORE USING ANY OF THESE COMMANDS

Note that when server names have been switched (databasemanager.switchServer),the
real server names must be used here, plugins.rawSQL is not transparent to switched servers.
****************************************************************************/

var action = SQL_ACTION_TYPES.DELETE_ACTION //pks deleted
//var action = SQL_ACTION_TYPES.INSERT_ACTION //pks inserted
//var action = SQL_ACTION_TYPES.UPDATE_ACTION //pks updates
var pksdataset = databaseManager.convertToDataSet(new Array(12,15,16,21))
var ok = plugins.rawSQL.notifyDataChange(databaseManager.getDataSourceServerName(controller.getDataSource()), 'employees', pksdataset,action)
serverName ;tableName ;pksDataset ;action ;ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow