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
{div:style=}
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.

\\ \\ Enter additional information related to this



Enter additional information related to this 'class'

inside

the

\

{div}

macro

with

'id=description'

{div} {div:id=description}{div}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{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:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{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) Execute any SQL, returns true if successful.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#executeSQL]\(serverName, tableName, sql, sql_args) Execute any SQL, returns true if successful.{td}{tr}{tbody}{tbody}{tr}{td}[JSDataSet]{td}{td}[#executeStoredProcedure]\(serverName, procedureDeclaration, arguments, inOutDirectionality, maxNumberOfRowsToRetrieve) 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:id=serverProperty|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Server Property Details{th}{tr}{tbody:id=servoy.rawSQL.allowClientCacheFlushes}{tr:id=name}{td}h6.servoy.rawSQL.allowClientCacheFlushes{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=executeSQL-String_String_String}{tr:id=name}{td}h6.executeSQL{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}executeSQL{span}{span}\(serverName, tableName, sql){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Execute any SQL, returns true if successful.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} serverName -- the name of the server \{[String]} tableName -- the name of the table \{[String]} sql -- the sql query to execute {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}

Div
iddescription


HTML Table
id
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

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

Table Cell (td)
#servoy.rawSQL.allowClientCacheFlushes

HTML Table
id
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#executeSQL(serverName, tableName, sql)
Execute any SQL, returns true if successful.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#executeSQL(serverName, tableName, sql, sql_args)
Execute any SQL, returns true if successful.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
#executeStoredProcedure(serverName, procedureDeclaration, arguments, inOutDirectionality, maxNumberOfRowsToRetrieve)
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
Table Row (tr)
idname
Table Cell (td)
servoy.rawSQL.allowClientCacheFlushes
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-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.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idexecuteSQL-String_String_String_ObjectArray
}{
Table Row (tr)
:
id
=
name
}{td}h6.executeSQL{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)
executeSQL
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}executeSQL{span}{span}\
executeSQL
Span
(serverName,
tableName,
sql,
sql_args)
{span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Execute any SQL, returns true if successful.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[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 {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
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.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idexecuteStoredProcedure-String_String_ObjectArray_NumberArray_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.executeStoredProcedure{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)
executeStoredProcedure
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
JSDataSet
]{span}{span:style=
Span
stylefont-weight:
bold;
}
executeStoredProcedure
{span}{span}\
Span
(serverName,
procedureDeclaration,
arguments,
inOutDirectionality,
maxNumberOfRowsToRetrieve)
{span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Execute a stored procedure.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} serverName \{[String]} procedureDeclaration \{[Object]\[]} arguments \{[Number]\[]} inOutDirectionality \{[Number]} maxNumberOfRowsToRetrieve {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSDataSet]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
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.
****************************************************************************/

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);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idflushAllClientsCache-String_String
}{
Table Row (tr)
:
id
=
name
}{td}h6.flushAllClientsCache{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)
flushAllClientsCache
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}
flushAllClientsCache
{span}{span}\
Span
(serverName,
tableName)
{span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Flush cached database data. Use with extreme care, its affecting the performance of clients!{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} serverName \{[String]} tableName {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
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. {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getException}{tr:id=name}{td}h6.getException{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[ServoyException]{span}{span:style=font-weight: bold;}getException{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}If the result from a function was false, it will return the exception object.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[ServoyException]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
 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.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idnotifyDataChange-String_String_JSDataSet_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.notifyDataChange{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)
notifyDataChange
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}
notifyDataChange
{span}{span}\
Span
(serverName,
tableName,
pksDataset,
action)
{span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Notify clients about changes in records, based on
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!
{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} serverName \{[String]} tableName \{[JSDataSet]} pksDataset \{[Number]} action {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
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.
****************************************************************************/

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)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)