This example connects
to Informix by using data source
testdsn
:
proc sql;
connect to informix
(user=SCOTT password=TIGER server=testdsn);
You can use the DBDATASRC
environment variable to set 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=testdsn);
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. In this example DBCON is a connection alias.
proc sql;
connect to informix as dbcon
(user=testuser using=testpass
server=testdsn);
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=testuser using=testpass
server=testdsn);
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=testdsn);
select * from connection to mydb
(execute procedure testproc('123456'));
disconnect from mydb;
quit;