Child pages
  • rawSQL

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
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


HTML Table
classservoy sSummery
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Server Property Summery
Table Body (tbody)
Table Row (tr)
Table Cell (td)

Table Cell (td)
#servoy.rawSQL.allowClientCacheFlushes

HTML Table
classservoy sSummery
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summery
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#executeSQL(serverName, tableName, SQL, [arguments])
Execute any SQL, returns true if successful.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
#executeStoredProcedure(serverName, procedureDeclaration, [arguments[], [IODirectionality[], maxNrReturnedRows)
Execute a stored procedure.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#flushAllClientsCache(serverName, tableName)
Flush cached database data.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
ServoyException
Table Cell (td)
#getException()
If the result from a function was false, it will return the exception object.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#notifyDataChange(serverName, tableName, pksDataset, action)
Notify clients about changes in records, based on pk(s).

HTML Table
idserverProperty
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Server Property Details
Table Body (tbody)
idservoy.rawSQL.allowClientCacheFlushes
classnode
Table Row (tr)
idname
Table Cell (td)
servoy.rawSQL.allowClientCacheFlushes
Table Row (tr)
iddes
Table Cell (td)
In case of performance problem you might want to disable this (true/false)
Table Row (tr)
classlastDetailRow
Table Cell (td)


HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Method Details
Table Body (tbody)
idexecuteSQL
classnode
Table Row (tr)
idname
Table Cell (td)
executeSQL
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
executeSQL
Span
stylefloat: left;
idiets
(serverName, tableName, SQL, [arguments])
Table Row (tr)
iddes
Table Cell (td)
Execute any SQL, returns true if successful.
Table Row (tr)
idprs
Table Cell (td)
Parameters
serverName
tableName
SQL
[arguments]
Table Row (tr)
idret
Table Cell (td)
Returns
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.
****************************************************************************/
//Execute any SQL, returns true if successful.
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')
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idexecuteStoredProcedure
classnode
Table Row (tr)
idname
Table Cell (td)
executeStoredProcedure
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
JSDataSet
Span
stylefloat: left; font-weight: bold;
idiets
executeStoredProcedure
Span
stylefloat: left;
idiets
(serverName, procedureDeclaration, [arguments[], [IODirectionality[], maxNrReturnedRows)
Table Row (tr)
iddes
Table Cell (td)
Execute a stored procedure.
Table Row (tr)
idprs
Table Cell (td)
Parameters
serverName
procedureDeclaration
[arguments[]
[IODirectionality[]
maxNrReturnedRows
Table Row (tr)
idret
Table Cell (td)
Returns
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.
****************************************************************************/
//Execute a stored procedure.
var maxReturnedRows = 10;//useful to limit number of rows
var procedure_declaration = '{?=calculate_interest_rate(?)}'
var args = new Array()
args[0] = java.sql.Types.NUMERIC
args[1] = 3000
//	define the types and direction, in this case a 0 for input data
var typesArray = new Array();
typesArray[0]=1;
typesArray[1]=0;
var dataset = plugins.rawSQL.executeStoredProcedure(controller.getServerName(), procedure_declaration, args, typesArray,maxReturnedRows);

//example to calc a strange total
global_total = 0;
for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
		global_total = global_total + dataset.getValue(i,1);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idflushAllClientsCache
classnode
Table Row (tr)
idname
Table Cell (td)
flushAllClientsCache
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
flushAllClientsCache
Span
stylefloat: left;
idiets
(serverName, tableName)
Table Row (tr)
iddes
Table Cell (td)
Flush cached database data. Use with extreme care, its affecting the performance of clients!
Table Row (tr)
idprs
Table Cell (td)
Parameters
serverName
tableName
Table Row (tr)
idret
Table Cell (td)
Returns
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.
****************************************************************************/
//Flush cached database data. Use with extreme care, its affecting the performance of clients!
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')
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idgetException
classnode
Table Row (tr)
idname
Table Cell (td)
getException
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
ServoyException
Span
stylefloat: left; font-weight: bold;
idiets
getException
Span
stylefloat: left;
idiets
()
Table Row (tr)
iddes
Table Cell (td)
If the result from a function was false, it will return the exception object.
Table Row (tr)
idret
Table Cell (td)
Returns
ServoyException
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idnotifyDataChange
classnode
Table Row (tr)
idname
Table Cell (td)
notifyDataChange
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
notifyDataChange
Span
stylefloat: left;
idiets
(serverName, tableName, pksDataset, action)
Table Row (tr)
iddes
Table Cell (td)
Notify clients about changes in records, based on pk(s). Use with extreme care, its affecting the performance of clients!
Table Row (tr)
idprs
Table Cell (td)
Parameters
serverName
tableName
pksDataset
action
Table Row (tr)
idret
Table Cell (td)
Returns
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.
****************************************************************************/
//Notify clients about changes in records, based on pk(s). Use with extreme care, its affecting the performance of clients!
var action = 1 //pks deleted
//var action = 2 //pks inserted
//var action = 3 //pks updates
var pksdataset = databaseManager.convertToDataSet(new Array(12,15,16,21))
var ok = plugins.rawSQL.notifyDataChange(controller.getServerName(), 'employees',pksdataset,action)
Table Row (tr)
classlastDetailRow
Table Cell (td)