Child pages
  • rawSQL

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
{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:class=servoy sSummery}{colgroup}{column:width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Server Property Summary{th}{tr}{tbody}{tr}{td}{td}{td}[#servoy.rawSQL.allowClientCacheFlushes] {td}{tr}{tbody}{table}\\ {table:class=servoy sSummery}{colgroup}{column:width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[Boolean]{td}{td}[#executeSQL]\(serverName, tableName, SQL, arguments) Execute any SQL, returns true if successful.{td}{tr}{tbody}{tbody}{tr}{td}[JSDataSet]{td}{td}[#executeStoredProcedure]\(serverName, procedureDeclaration, arguments[, IODirectionality[, maxNrReturnedRows) Execute a stored procedure.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#flushAllClientsCache]\(serverName, tableName) Flush cached database data.{td}{tr}{tbody}{tbody}{tr}{td}[ServoyException]{td}{td}[#getException]\() If the result from a function was false, it will return the exception object.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#notifyDataChange]\(serverName, tableName, pksDataset, action) Notify clients about changes in records, based on pk(s).{td}{tr}{tbody}{table}\\ {table:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Server Property Details{th}{tr}{tbody:id=5C3EACFD-C774-4147-8F58-93C966B84602}{tr:id=name}{td}h6.servoy.rawSQL.allowClientCacheFlushes{td}{tr}{tr:id=des}{td}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_des|text=|trigger=button}{sub-section}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_des|trigger=none|class=sIndent}In case of performance problem you might want to disable this (true/false){sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=ret}{td}*Returns*\\{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_ret|text=|trigger=button}{sub-section}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_ret|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_see|text=|trigger=button}{sub-section}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_see|text=|trigger=button}{sub-section}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_sam|text=|trigger=button}{sub-section}{sub-section:5C3EACFD-C774-4147-8F58-93C966B84602_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\ {table:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=0CB67666-5021-441B-8212-D81B9D724E03}{tr:id=name}{td}h6.executeSQL{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}executeSQL{span}{span:id=iets|style=float: left;}\(serverName, tableName, SQL, arguments){span}{td}{tr}{tr:id=des}{td}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_des|text=|trigger=button}{sub-section}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_des|trigger=none|class=sIndent}Execute any SQL, returns true if successful.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_prs|trigger=none}serverName tableName SQL \[arguments\] {sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_ret|text=|trigger=button}{sub-section}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_see|text=|trigger=button}{sub-section}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_see|text=|trigger=button}{sub-section}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_sam|text=|trigger=button}{sub-section}{sub-section:0CB67666-5021-441B-8212-D81B9D724E03_sam|class=sIndent|trigger=none}{code:language=javascript} /**************************************************************************** WARNING! You can cause data loss
Wiki Markup
Div
styledisplay: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.

Div
iddescription



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Server Property Summary
Table Row (tr)
Table Cell (td)
 
Table Cell (td)
servoy.rawSQL.allowClientCacheFlushes



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
executeSQL(serverName, tableName, sql)
Execute any SQL, returns true if successful.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
executeSQL(serverName, tableName, sql, sql_args)
Execute any SQL, returns true if successful.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
executeStoredProcedure(serverName, procedureDeclaration, arguments, inOutDirectionality, maxNumberOfRowsToRetrieve)
Execute a stored procedure.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
flushAllClientsCache(serverName, tableName)
Flush cached database data.
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 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
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
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)
 



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
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.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
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.
****************************************************************************/
//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')
}
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=48FCA812-9C3F-40A7-B1CA-8F06F7755A57}{tr:id=name}{td}h6.executeStoredProcedure{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSDataSet]{span}{span:id=iets|style=float: left; font-weight: bold;}executeStoredProcedure{span}{span:id=iets|style=float: left;}\(serverName, procedureDeclaration, arguments[, IODirectionality[, maxNrReturnedRows){span}{td}{tr}{tr:id=des}{td}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_des|text=|trigger=button}{sub-section}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_des|trigger=none|class=sIndent}Execute a stored procedure.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_prs|trigger=none}serverName procedureDeclaration \[arguments[\] \[IODirectionality[\] maxNrReturnedRows {sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_ret|text=|trigger=button}{sub-section}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_ret|trigger=none|class=sIndent}[JSDataSet]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_see|text=|trigger=button}{sub-section}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_see|text=|trigger=button}{sub-section}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_sam|text=|trigger=button}{sub-section}{sub-section:48FCA812-9C3F-40A7-B1CA-8F06F7755A57_sam|class=sIndent|trigger=none}{code:language=javascript} /**************************************************************************** WARNING! You can

// 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.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idexecuteStoredProcedure-String_String_ObjectArray_NumberArray_Number
Table Row (tr)
idname
Table Cell (td)

executeStoredProcedure

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
executeStoredProcedure
Span
(serverName, procedureDeclaration, arguments, inOutDirectionality, maxNumberOfRowsToRetrieve)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Execute a stored procedure.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} serverName
{String} procedureDeclaration
{Object[]} arguments
{Number[]} inOutDirectionality
{Number} maxNumberOfRowsToRetrieve
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.
****************************************************************************/
//Execute

a stored procedure.
var maxReturnedRows = 10; //useful to limit number of rows
var procedure_declaration = '{?=calculate_interest_rate(?)}'
var
// 
args
define 
=
the 
new Array() args[0] = java.sql.Types.NUMERIC args[1] = 3000 //
direction, a 0 for input data, a 1 for output data
var typesArray = [1, 0];
// define the types and 
direction
values, 
in this case
a 
0
value for input data, 
var
a 
typesArray
sql-type 
=
for 
new Array(); typesArray[0]=1; typesArray[1]=0; var dataset
output data
var args = 
plugins
[java.
rawSQL
sql.
executeStoredProcedure(controller.getServerName(), procedure_declaration, args, typesArray,maxReturnedRows);
Types.NUMERIC, 3000]
//
example
 
to
A 
calc
dataset 
a
is 
strange
returned, 
total
when 
global_total = 0; for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ ) { global_total = global_total + dataset.getValue(i,1); } {code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=AC4BEE64-885C-4306-9994-955977681C53}{tr:id=name}{td}h6.flushAllClientsCache{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}flushAllClientsCache{span}{span:id=iets|style=float: left;}\(serverName, tableName){span}{td}{tr}{tr:id=des}{td}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_des|text=|trigger=button}{sub-section}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_des|trigger=none|class=sIndent}Flush cached database data. Use with extreme care, its affecting the performance of clients!{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:AC4BEE64-885C-4306-9994-955977681C53_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_prs|trigger=none}serverName tableName {sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:AC4BEE64-885C-4306-9994-955977681C53_ret|text=|trigger=button}{sub-section}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:AC4BEE64-885C-4306-9994-955977681C53_see|text=|trigger=button}{sub-section}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:AC4BEE64-885C-4306-9994-955977681C53_see|text=|trigger=button}{sub-section}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:AC4BEE64-885C-4306-9994-955977681C53_sam|text=|trigger=button}{sub-section}{sub-section:AC4BEE64-885C-4306-9994-955977681C53_sam|class=sIndent|trigger=none}{code:language=javascript} /******
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);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
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.
**********************************************************************
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') } {code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A}{tr:id=name}{td}h6.getException{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[ServoyException]{span}{span:id=iets|style=float: left; font-weight: bold;}getException{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_des|text=|trigger=button}{sub-section}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_des|trigger=none|class=sIndent}If the result from a function was false, it will return the exception object.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_ret|text=|trigger=button}{sub-section}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_ret|trigger=none|class=sIndent}[ServoyException]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_see|text=|trigger=button}{sub-section}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_see|text=|trigger=button}{sub-section}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_sam|text=|trigger=button}{sub-section}{sub-section:9D9BFF1C-4787-4986-9EF0-B2A3AFD4471A_sam|class=sIndent|trigger=none}{builder-show:permission=edit}{code:language=javascript} {code}{builder-show}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=CA12B197-B764-4A3C-B8E9-DC463A3B51D4}{tr:id=name}{td}h6.notifyDataChange{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}notifyDataChange{span}{span:id=iets|style=float: left;}\(serverName, tableName, pksDataset, action){span}{td}{tr}{tr:id=des}{td}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_des|text=|trigger=button}{sub-section}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_des|trigger=none|class=sIndent}Notify clients about changes in records, based on pk(s). Use with extreme care, its affecting the performance of clients!{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_prs|trigger=none}serverName tableName pksDataset action {sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_ret|text=|trigger=button}{sub-section}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_see|text=|trigger=button}{sub-section}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_see|text=|trigger=button}{sub-section}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_sam|text=|trigger=button}{sub-section}{sub-section:CA12B197-B764-4A3C-B8E9-DC463A3B51D4_sam|class=sIndent|trigger=none}{code:language=javascript}
******/

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.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
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.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnotifyDataChange-String_String_JSDataSet_Number
Table Row (tr)
idname
Table Cell (td)

notifyDataChange

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
notifyDataChange
Span
(serverName, tableName, pksDataset, action)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
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

Div
classsIndent
{String} serverName
{String} tableName
{JSDataSet} pksDataset
{Number} action
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.
****************************************************************************/
//Notify clients about changes in records, based on pk(s). Use with extreme care, its affecting the performance of clients!

var action = 
1
SQL_ACTION_TYPES.DELETE_ACTION //pks deleted
//var action = 
2
SQL_ACTION_TYPES.INSERT_ACTION //pks inserted
//var action = 
3
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.
getServerName
getDataSource()), 'employees', pksdataset,action)
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)