ALLBASE/SQL Reference Manual (36216-90216)

418 Chapter11
SQL Statements E - R
EXECUTE
authorization the dynamically preprocessed statement itself requires.
Examples
1. Interactive execution
isql=> PREPARE Statistics(1)
> FROM 'UPDATE STATISTICS FOR TABLE PurchDB.Orders'
isql=> PREPARE Statistics(2)
> FROM 'UPDATE STATISTICS FOR TABLE PurchDB.OrderItems'
Two sections for module Statistics are stored in the system catalog.
isql=> EXECUTE Statistics(1)
The statistics for table PurchDB.Orders are updated.
isql=> EXECUTE Statistics(2)
The statistics for table PurchDB.OrderItems are updated.
isql=> DROP MODULE Statistics
Both sections of the module are deleted.
2. Programmatic execution
If you know that the statement to be dynamically preprocessed is not a SELECT
statement and does not contain dynamic parameters, you can prepare it and execute it
in one step, as follows:
EXECUTE IMMEDIATE :Dynam1
You can prepare and execute the statement in separate operations. For example, if you
don't know the format of a statement, you could do the following:
PREPARE Dynamic1 FROM :Dynam1
The statement stored in :Dynam1 is dynamically preprocessed.
DESCRIBE Dynamic1 INTO SqldaOut
If Dynamic1 is not a SELECT statement, the Sqld field of the Sqlda data structure is 0. If
you know there are no dynamic parameters in the prepared statement, use the EXECUTE
statement to execute the dynamically preprocessed statement.
If it is possible that dynamic parameters are in the prepared statement, you must
describe the statement for input:
DESCRIBE INPUT Dynamic1 USING SQL DESCRIPTOR SqldaIn