Chapter Contents |
Previous |
Next |
EXECUTE Statement |
Optional statement |
Syntax | |
Arguments | |
Useful Statements to Include in EXECUTE Statements | |
Special Informix Considerations | |
Examples |
Syntax |
EXECUTE (DBMS-specific SQL-statement) BY dbms-name | alias; |
Note: If you use quotes in your
Informix SQL Pass-through statements, your DELIMIDENT environment variable
must be set to DELIMIDENT=YES, or your statements will be rejected by Informix.
Any return code or message that is generated by the DBMS is available in the macro variables SQLXRC and SQLXMSG after the statement executes.
informix
. The keyword BY must appear before the dbms-name argument.
You must specify either a DBMS name or an alias in the EXECUTE statement. The EXECUTE statement sends dynamic, non-query DBMS-specific SQL statements to the DBMS and processes those statements.
In some SAS/ACCESS interfaces, you can issue an EXECUTE statement directly without first connecting to a DBMS. If you omit the CONNECT statement, an implicit connection is performed (by using default values for all connection arguments) when the first EXECUTE statement is passed to the DBMS.
The EXECUTE statement cannot be stored as part of a Pass-Through query in a PROC SQL view.
Useful Statements to Include in EXECUTE Statements |
This section lists some of the statements that you can pass to the DBMS by using the Pass-Through facility's EXECUTE statement.
Note: The statements passed using the EXECUTE statement cannot
contain a semicolon (;) because to SAS software a semicolon represents the
end of a statement.
For more information and restrictions on these and other SQL statements, see your Informix SQL documentation.
Special Informix Considerations |
Stored procedures that do not return values can be executed
directly by using the Informix SQL EXECUTE statement. Stored procedure execution
is initiated with the Informix EXECUTE PROCEDURE statement. The following
example executes the stored procedure
make_table.
The stored
procedure has no input parameters and returns no values.
execute (execute procedure make_table()) by informix;
Stored procedures that return values must be executed
by using the PROC SQL SELECT statement with a CONNECTION TO component. The
following example executes the stored procedure
read_address
, which has
one parameter,
"Putnum".
The values that are returned by
read_address
serve as the contents of a virtual table for the PROC SQL SELECT statement.
select * from connection to informix (execute procedure read_address ("Putnum"));
For example, when you try to execute a stored procedure that returns values from a PROC SQL EXECUTE statement, you get the following error message:
execute (execute procedure read_address ("Putnum")) by informix; ERROR: Informix EXECUTE Error: Procedure (read_address) returns too many values.
Examples |
The following example grants UPDATE and INSERT authority
to user
gomez
on the Informix ORDERS table. Because the
CONNECT statement is omitted, an implicit connection is made that uses a default
value of
informix
as the connection alias and default values
for the DATABASE and SERVER arguments. Informix is a case-sensitive database;
therefore, the database object
ORDERS
is in uppercase,
as it was created.
proc sql; execute (grant update, insert on ORDERS to gomez) by informix; quit;
The next example connects to Informix and drops (that
is, removes) the table
tempdata
from the
stores7
database. The alias
temp5
that is specified in the CONNECT
statement is used in the EXECUTE statement's BY clause.
proc sql; connect to informix as temp5 (database='//online/stores7'); execute (drop table tempdata) by temp5; disconnect from temp5; quit;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.