SqlScript()

Previous Next

Performs ad-hoc SQL data manipulation through the Rules Engine.

Syntax

SqlScript(<script>)

Parameters

Script

Script consisting of SQL statements and/or actions.

In previous versions of USoft Developer, SqlScript() was used for a variety of purposes. SqlScript() will remain backward compatible in all respects. However, the core functionality of SqlScript is now to perform data manipulation (INSERT / UPDATE / DELETE) where a method call is expected.

· To SELECT data from the database where a method call is expected, and then process these retrieved data, call a Decision.

 

· To write SQL expressions, use FORMULA().

The script may contain any statement used in the SQL Command tool. You can execute multiple SQL statements, separated by semicolons (;), provided that you start the script with:

SET QuitZeroRows False

The script may also contain an embedded SET statement determining how messages are displayed:

SET showMessages [True | False]

Default = False. If set to True, all messages of the Rules Engine are shown. If set to False, no messages are shown.

SET showErrorMessages [True | False]

Default = False. If set to True, and showMessages is set to False only messages for real errors such as constraint violations are shown.

This is only the case for constraints that are evaluated as a result of direct action (SqlScript()). It does not affect messages generated when corrective constraints cause restrictive constraints to be evaluated (triggered by decisions). Such messages are an indication that you have implemented contradictory rules and are always shown.

If you wish to turn off the display of ALL messages, you can use the -xrm "*messagesToFile: True" setting as a command line parameter when starting your application. This redirects all messages to a file. In this case, you will not see ANY messages. The file is named Messages .log, and is located in the standard logging folder specified during USoft setup.

Example

SqlScript(UPDATE CUSTOMER SET STATUS = 'A' WHERE ID = :"query.cust_id()")