13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface to ODBC 4 Connection to Component Examples 663This example uses the connection method that represents a more advanced level ofODBC con<strong>for</strong>mance. It uses the input dialog box that is provided by the driver. TheDATASRC= and USER= arguments are within the connection string. The SQLpass-through facility there<strong>for</strong>e does not parse them but instead passes them to theODBC manager.proc sql;connect to odbc as user1(required = "dsn=User’s Data;uid=testuser");This example enables you to select any data source that is configured on yourmachine. The example uses the connection method that represents a more advancedlevel of ODBC con<strong>for</strong>mance, Level 1. When connection succeeds, the connection stringis returned in the SQLXMSG and SYSDBMSG macro variables and can be stored if thismethod is used to configure a connection <strong>for</strong> later use.proc sql;connect to odbc (required);This next example prompts you to specify the in<strong>for</strong>mation that is required to make aconnection to the DBMS. You are prompted to supply the data source name, user ID,and password in the dialog boxes that display.proc sql;connect to odbc (prompt);Connection to Component ExamplesThis example sends an Oracle SQL query (presented in highlighted text) to theOracle database <strong>for</strong> processing. The results from the query serve as a virtual table <strong>for</strong>the PROC SQL FROM clause. In this example MYCON is a connection alias.proc sql;connect to odbc as mycon(datasrc=ora7 user=testuser password=testpass);select *from connection to mycon(select empid, lastname, firstname,hiredate, salaryfrom sasdemo.employeeswhere hiredate>=’31.12.1988’);disconnect from mycon;quit;This next example gives the previous query a name and stores it as the SQL viewSamples.Hires88. The CREATE VIEW statement appears highlighted.libname samples ’<strong>SAS</strong>-data-library’;proc sql;connect to odbc as mycon(datasrc=ora7 user=testuser password=testpass);create view samples.hires88 asselect *from connection to mycon

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!