For general information about this feature, see SQL Pass-Through Facility.
Here are the SQL pass-through facility specifics for the Informix interface.
informix.informix is
automatically used.The SQL pass-through facility recognizes two types of stored procedures in Informix that perform only database functions. The methods for executing the two types of stored procedures are different.
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. This example executes the stored procedure read_address,
which has one parameter, "Putnum".
The values that read_address returns
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 receive this error message:
execute (execute procedure read_address
("Putnum")) by informix;
ERROR: Informix EXECUTE Error: Procedure
(read_address) returns too many values.
Informix SQL contains extensions to the ANSI-89 standards. Some of these extensions, such as LOAD FROM and UNLOAD TO, are restricted from use by any applications other than the Informix DB-Access product. Specifying these extensions in the PROC SQL EXECUTE statement generates this error:
-201
A syntax error has occurred
This example connects
to Informix by using data source mysrv1:
proc sql;
connect to informix
(user=myusr1 password=mypwd1 server=mysrv1);
You can use the DBDATASRC environment variable to specify the default data source.
This next 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. The connection uses a default value
of informix as the connection alias and default
values for the SERVER= argument.
proc sql;
execute (grant update, insert on ORDERS to gomez) by informix;
quit;
This example connects to Informix and drops (removes) the table TempData from the 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
(server=mysrv1);
execute (drop table tempdata) by temp5;
disconnect from temp5;
quit;
This example sends an SQL query, shown with highlighting, to the database for processing. The results from the SQL query serve as a virtual table for the PROC SQL FROM clause. DBCON is a connection alias in this example.
proc sql;
connect to informix as dbcon
(user=myusr1 using=mypwd1
server=mysrv1);
select *
from connection to dbcon
(select empid, lastname, firstname,
hiredate, salary
from employees
where hiredate>='31JAN88');
disconnect from dbcon;
quit;
This next example gives the previous query a name and stores it as the PROC SQL view Samples.Hires88. The CREATE VIEW statement appears in highlighting.
libname samples 'SAS-library';
proc sql;
connect to informix as mycon
(user=myusr1 using=mypwd1
server=mysrv1);
create view samples.hires88 as
select *
from connection to mycon
(select empid, lastname, firstname,
hiredate, salary from employees
where hiredate>='31JAN88');
disconnect from mycon;
quit;
This example connects
to Informix and executes the stored procedure testproc.
The select * clause displays the results
from the stored procedure.
proc sql;
connect to informix as mydb
(server=mysrv1);
select * from connection to mydb
(execute procedure testproc('123456'));
disconnect from mydb;
quit;