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.

Data Integrity and Security 4 Controlling DBMS Connections 29Defining Views and SchemasIf you want to provide access to some but not all fields in a DBMS table, create a<strong>SAS</strong> view that prohibits access to the sensitive data by specifying that particularcolumns be dropped. Columns that are dropped from views do not affect the underlyingDBMS table and can be reselected <strong>for</strong> later use.Some <strong>SAS</strong>/<strong>ACCESS</strong> engines support LIBNAME options that restrict or qualify thescope, or schema, of the tables in the libref. For example, the DB2 engine supports theAUTHID= and LOCATION= options, and the Oracle engine supports the SCHEMA=and DBLINK= options. See the <strong>SAS</strong>/<strong>ACCESS</strong> documentation <strong>for</strong> your DBMS todetermine which options are available to you.This example uses <strong>SAS</strong>/<strong>ACCESS</strong> Interface to Oracle:libname myoralib oracle user=testuser password=testpasspath=’myoraserver’ schema=testgroup;proc datasets lib=myoralib;run;In this example the MYORALIB libref is associated with the Oracle schema namedTESTGROUP. The DATASETS procedure lists only the tables and views that areaccessible to the TESTGROUP schema. Any reference to a table that uses the librefMYORALIB is passed to the Oracle server as a qualified table name; <strong>for</strong> example, if the<strong>SAS</strong> program reads a table by specifying the <strong>SAS</strong> data set MYORALIB.TESTTABLE,the <strong>SAS</strong>/<strong>ACCESS</strong> engine passes the following query to the server:select * from "testgroup.testtable"Controlling DBMS ConnectionsBecause the overhead of executing a connection to a DBMS server can beresource-intensive, <strong>SAS</strong>/<strong>ACCESS</strong> supports the CONNECTION= and DEFER= optionsto control when a DBMS connection is made, and how many connections are executedwithin the context of your <strong>SAS</strong>/<strong>ACCESS</strong> application. For most <strong>SAS</strong>/<strong>ACCESS</strong> engines, aconnection to a DBMS begins one transaction, or work unit, and all statements issuedin the connection execute within the context of the active transaction.The CONNECTION= LIBNAME option enables you to specify how many connectionsare executed when the library is used and which operations on tables are shared withina connection. By default, the value is CONNECTION=SHAREDREAD, which meansthat a <strong>SAS</strong>/<strong>ACCESS</strong> engine executes a shared read DBMS connection when the libraryis assigned. Every time a table in the library is read, the read-only connection is used.However, if an application attempts to update data using the libref, a separateconnection is issued, and the update occurs in the new connection. As a result, there isone connection <strong>for</strong> read-only transactions and a separate connection <strong>for</strong> each updatetransaction.In the example below, the <strong>SAS</strong>/<strong>ACCESS</strong> engine issues a connection to the DBMSwhen the libref is assigned. The PRINT procedure reads the table by using the firstconnection. When the PROC SQL updates the table, the update is per<strong>for</strong>med with asecond connection to the DBMS.libname myoralib oracle user=testuser password=testpasspath=’myoraserver’;proc print data=myoralib.mytable;run;

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

Saved successfully!

Ooh no, something went wrong!