
228 Syntax for the Pass-Through Facility for Relational Databases Chapter 12
retrieve data directly from a DBMS using the facilities CONNECTION TO
component in the FROM clause of a PROC SQL SELECT statement.
You can use Pass-Through Facility statements in a PROC SQL query or you can store
them in a PROC SQL view. When you create a PROC SQL view, any arguments that you
specify in the CONNECT statement are stored with the view. Therefore, when the view
is used in a SAS program, SAS can establish the appropriate connection to the DBMS.
Syntax for the Pass-Through Facility for Relational Databases
This section presents the syntax for the Pass-Through Facility statements and the
CONNECTION TO component. For DBMS-specific details, see the documentation for
your SAS/ACCESS interface.
PROC SQL <option(s)>;
CONNECT TO dbms-name <AS alias><(<database-connection-arguments>
<connect-statement-arguments>)>;
DISCONNECT FROM dbms-name | alias;
EXECUTE (dbms-specific-SQL-statement)BYdbms-name | alias;
SELECT column-list FROM CONNECTION TO dbms-name | alias (dbms-query)
Return Codes
As you use the PROC SQL statements that are available in the Pass-Through
Facility, any error return codes and error messages are written to the SAS log. These
codes and messages are available to you through the following two SAS macro variables:
SQLXRC
contains the DBMS return code that identifies the DBMS error.
SQLXMSG
contains descriptive information about the DBMS error that is generated by the
DBMS.
The contents of the SQLXRC and SQLXMSG macro variables are printed in the SAS
log using the %PUT macro. They are reset after each Pass-Through Facility statement
has been executed.
See “Macro Variables for Relational Databases” on page 219 for more information
about these return codes.
CONNECT Statement
Establishes a connection with the DBMS
Valid in: PROC SQL steps (when accessing DBMS data using SAS/ACCESS software)
Syntax
CONNECT TO dbms-name <AS alias><(<database-connection-arguments>
<connect-statement-arguments>)>;