Index...
Centrallix Documentation
|
6.14 EXEC Statements
EXEC Statements
Sometimes, you need to call another query object, and your intent is to run that object as a procedure rather than to simply obtain its result set. In that case, for clarity, the EXEC statement can be used.
EXEC /path/to/datasource.qy param1=value1, param2=value2, ...
The EXEC statement also makes it much simpler to pass parameters. Parameters are provided in the same syntax as SELECTed attributes.
EXEC vs SELECT
An EXEC statement is syntactic sugar for a simple SELECT statement using a data source that accepts parameters. For example, this EXEC statement:
EXEC /applications/update_user.qy
user=:userdata:username,
description=:userdata:userdesc
is mostly the same as the following SELECT statement:
SELECT
*
FROM
expression('/applications/update_user.qy?user='
+ :userdata:username
+ '&description='
+ :userdata:userdesc)
The main difference, other than the syntactic simplicity of EXEC, is that the EXEC statement automatically does the appropriate URL encoding to encode the parameters, so EXEC is much safer to use, especially if your parameter values can be influenced by the user.
EXEC statements can return a result set in the same way that SELECT statements can.
Comments...
(none yet)
Add a Comment...
|