Command Statement
A command statement executes an SQL Command such as SELECT, INSERT, UPDATE, DELETE, EXECUTE, or a DDL statement, dynamic SQL, etc. against one or more data sources.
Usage
command [(WITH|WITHOUT) RETURN];
Syntax
EXECUTEcommand statements may accessIN/OUT,OUT, andRETURNparameters. To access the return value the statement will have the formvar = EXEC proc.... To accessOUTorIN/OUTvalues named parameter syntax must be used. For example,EXEC proc(in_param=>'1', out_param=>var) will assign the value of theOUTparameter to the variablevar. It is expected that the data type of a parameter will be implicitly convertible to the datatype of the variable;
The
RETURNclause determines if the result of the command is returnable from the procedure. The default isWITH RETURN. If the command does not return a result set or the procedure does not return a result set, theRETURNclause is ignored. IfWITH RETURNis specified, the result set of the command must match the expected result set of the procedure. Only the last successfully executed statement executedWITH RETURNwill be returned as the procedure result set. If there are no returnable result sets and the procedure declares that a result set will be returned, then an empty result set is returned.
Examples
Command Statement Without Return
BEGIN
EXECUTE 'SELECT 1' WITHOUT RETURN;
END ;;
Command Statement With Return
BEGIN
EXECUTE 'SELECT 1' [WITH RETURN];
END ;;
The default is WITH RETURN, so the part in square brackets can be omitted.