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.

30 Locking, Transactions, and Currency Control 4 Chapter 3proc sql;update myoralib.mytable set acctnum=123where acctnum=456;quit;This example uses <strong>SAS</strong>/<strong>ACCESS</strong> Interface to DB2 under z/OS. The LIBNAMEstatement executes a connection by way of the DB2 Call Attach Facility to the DB2DBMS server:libname mydb2lib db2 authid=testuser;If you want to assign more than one <strong>SAS</strong> libref to your DBMS server, and if you donot plan to update the DBMS tables, <strong>SAS</strong>/<strong>ACCESS</strong> enables you to optimize the way inwhich the engine per<strong>for</strong>ms connections. Your <strong>SAS</strong> librefs can share a single read-onlyconnection to the DBMS if you use the CONNECTION=GLOBALREAD option. Thefollowing example shows you how to use the CONNECTION= option with the<strong>ACCESS</strong>= option to control your connection and to specify read-only data access.libname mydblib1 db2 authid=testuserconnection=globalread access=readonly;If you do not want the connection to occur when the library is assigned, you candelay the connection to the DBMS by using the DEFER= option. When you specifyDEFER=YES in the LIBNAME statement, the <strong>SAS</strong>/<strong>ACCESS</strong> engine connects to theDBMS the first time a DBMS object is referenced in a <strong>SAS</strong> program:libname mydb2lib db2 authid=testuser defer=yes;Note: If you use DEFER=YES to assign librefs to your DBMS tables and views inan AUTOEXEC program, the processing of the AUTOEXEC file is faster because theconnections to the DBMS are not made every time <strong>SAS</strong> is invoked. 4Locking, Transactions, and Currency Control<strong>SAS</strong>/<strong>ACCESS</strong> provides options that enable you to control some of the row, page, ortable locking operations that are per<strong>for</strong>med by the DBMS and the <strong>SAS</strong>/<strong>ACCESS</strong> engineas your programs are executed. For example, by default, the <strong>SAS</strong>/<strong>ACCESS</strong> Oracleengine does not lock any data when it reads rows from Oracle tables. However, you canoverride this behavior by using the locking options that are supported in <strong>SAS</strong>/<strong>ACCESS</strong>Interface to Oracle.To lock the data pages of a table while <strong>SAS</strong> is reading the data to prevent otherprocesses from updating the table, use the READLOCK_TYPE= option, as shown in thefollowing example:libname myoralib oracle user=testuser pass=testpasspath=’myoraserver’ readlock_type=table;data work.mydata;set myoralib.mytable(where=(colnum > 123));run;In this example, the <strong>SAS</strong>/<strong>ACCESS</strong> Oracle engine obtains a TABLE SHARE lock onthe table so that other processes cannot update the data while your <strong>SAS</strong> program readsit.In the next example, Oracle acquires row-level locks on rows read <strong>for</strong> update in thetables in the libref.

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

Saved successfully!

Ooh no, something went wrong!