1 Cache the PreparedStatement
The execution of a SQL procedure from XSQL_Script is performed using unPreparedStatement, is a Java object which allows to perform the execution of a stored procedure (and other many operations) from the driver JDBC. The tag execute-procedure allows through the attribute prepare-cache (true|false by default true) determines if you should cache it or not the PreparedStatement. By default this PreparedStatement is cached and can be reusable in sucessive calls to the same procedure and only you just have to set the values for the input and output arguments, optimizing the response time because this object is not rebuilt. The PreparedStatement is not cached when:
- The procedure has not arguments.
- The prepare cache has been globally disabled.
- The prepare cache for this call through this attribute has been disabled.
2 Cache a call to a procedure
The tag execute-procedure allows to cache a call to a precedure. This implies that the value of the output arguments, established by the procedure during the execution, are cached and the following calls to this procedure for the same input arguments will obtain the sames values in the output arguments (the cached values). It has the sense that it is considered invariant the procedure inside of the execution block. It should be used when the procedure is considered invariant. The following call to the procedure is performed with cache of result.
<execute-procedure name='myproc' cache='true'> <in> <today /> <arg1 /> </in> <out> <var name='a' /> <var name='b' type='integer' /> <var name='c' type='decimal' /> <var name='e' type='date' /> </out> </execute-procedure>
If you perform the call with cache of results and the procedure does not have output arguments, an exception is produced:
unable to cache non returning procedure calls
Execute a compiled procedure SQL in the database. A procedure can have input and output arguments. The value of the possibles output arguments are established in the procedure and are recovered and accessibles in XSQL-Script through its name.
<execute-function
name='name'
cache='cache'
prepared-cache='true|false'
>
<in> *
<argument_in /> *
</in>
<out> *
<var
name='name'
type='string|boolean|smallint|integer|bigint|float|double|decimal|date|time|timestamp|blob'
/> *
</out>
</execute-function>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the procedure. | |||
Acache | boolean | Indicate if the result should be cached. In this case, the following calls to this function with same input arguments will obtain the cached value for the output arguments. It should be used when the function is invariant for the block. | |||
Aprepared-cache | boolean |
Indicate if the PreparedStatement used to perform the execution is cached. By default, it is cached. It is not cached when:
|
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Ein | null | Block for the input arguments of the procedure. The procedure receives this values for its execution. | |||
Eargument_in | object | Input arguments of the called function. It is possible that the function does not have any input argument, one or several. The data type and the data will depend of the function. | |||
Eout | null | Block for the output arguments of the procedure, if any. The procedure establishes this values during the execution. | |||
Evar | null | Argumento de salida del procedimiento. | |||
Aname | string | Name of the output argument. This is the name which will be used previously to access to the value of the variable. | |||
Atype | string | Data type established in the procedure for this variable. (output argument). |
Returns | |
---|---|
Type | Description |
object | Returns ONE (1, true) if the execution has been performed successfully. |
Exceptions
unsupported type for out: ...
The value established for a output argument is of a type not supported by the system.
unable to cache non returning procedure calls
If the call was performed with results cache and the procedure does not have output arguments.
SQLException ...
Excepciones provoked during the execution of the procedure.
Performs the call to the procedure myproc passing him the current date and an entry argument of the XSQL-Script, and it establishes the value for 4 output arguments which are recuperated and are accessibles through the name.
<xsql-script name='script_test_proc'> <args> <arg name='arg1' /> </args> <body> <execute-procedure name='myproc'> <in> <today /> <arg1 /> </in> <out> <var name='a' /> <var name='b' type='integer' /> <var name='c' type='decimal' /> <var name='e' type='date' /> </out> </execute-procedure> <println>Value established in the procedure for 'a': <a /></println> </body> </xsql-script>