3. Statements : OpenROAD SQL Statements : Execute Immediate Statement : Execute Immediate Description
 
Share this page                  
Execute Immediate Description
The execute immediate statement executes a dynamically built statement string. This statement does not name or encode the statement and cannot supply parameters.
The execute immediate can be used:
If a dynamic statement needs to be executed just once in your program
In drop statements, where the name of the object to be dropped is not known at the time the program is compiled
The execute immediate statement must be terminated according to the rules of the host language. If the statement string is blank or empty, the DBMS Server returns a runtime syntax error.
The following SQL statements cannot be executed using execute immediate:
call
close
connect
declare
disconnect
enddata
fetch
get data
get dbevent
help
include
inquire_sql
open
prepare to commit
put data
set_sql
whenever
Other dynamic SQL statements
The statement string must not include references to variable names. If your statement string includes embedded quotes, it is easiest to specify the string in a 4GL language variable. If a string that includes quotes as a string constant is to be specified, remember that quoted characters within the statement string must follow the 4GL SQL string delimiting rules.
The into clause can only be used when the statement string is a select statement. The into clause specifies variables to store the values returned by a select. Use this option when the program knows the data types and lengths of the result columns before the select executes. The data type of the variables must be compatible with the associated result columns.