Command Statement
A command statement executes an SQL command such as SELECT
, INSERT
, UPDATE
, DELETE
, EXECUTE
, or a dynamic SQL command, etc., against one or more data sources.
Usage
command [(WITH|WITHOUT) RETURN];
Syntax
EXECUTE
command statements may accessIN/OUT
,OUT
, andRETURN
parameters. To access the return value, the statement will have the formvar = EXEC proc...
. To accessOUT
orIN/OUT
values named parameter syntax must be used. For example,EXEC proc(in_param=>'1', out_param=>var
) will assign the value of theOUT
parameter to the variablevar
. It is expected that the data type of a parameter will be implicitly convertible to the datatype of the variable;
- The
RETURN
clause 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, theRETURN
clause is ignored. IfWITH RETURN
is specified, the result set of the command must match the expected result set of the procedure. Only the last successfully executed statement executedWITH RETURN
will 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.