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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

836 Examples 4 Chapter 28Here is what <strong>SAS</strong>/<strong>ACCESS</strong> does in the above example.3 Connects to the Teradata DBMS and specifies the three <strong>SAS</strong>/<strong>ACCESS</strong>LIBNAME read lock options.3 Opens the PURCHASES table and obtains an <strong>ACCESS</strong> lock if a differentuser does not hold an EXCLUSIVE lock on the table.3 Reads and displays table rows with a value less than 2 in the BILL column.3 Closes the PURCHASES table and releases the <strong>ACCESS</strong> lock.3 Opens the PURCHASES table again and obtains an <strong>ACCESS</strong> lock if adifferent user does not hold an EXCLUSIVE lock on the table.3 Reads table rows with a value greater than 1000 in the QUANTITY column.3 Closes the PURCHASES table and releases the <strong>ACCESS</strong> lock.Setting Isolation Level to WRITE to Update a Teradata Table/* This updates the critical Rebate row. */libname cust teradata user=testuser password=testpass;proc sql;update cust.purchases(UPDATE_ISOLATION_LEVEL=WRITEUPDATE_MODE_WAIT=YESUPDATE_LOCK_TYPE=TABLE)set rebate=10 where bill>100;quit;In this example here is what <strong>SAS</strong>/<strong>ACCESS</strong> does:3 Connects to the Teradata DBMS and specifies the three <strong>SAS</strong>/<strong>ACCESS</strong> data setupdate lock options.3 Opens the PURCHASES table and obtains a WRITE lock if a different user doesnot hold a READ, WRITE, or EXCLUSIVE lock on the table.3 Updates table rows with BILL greater than 100 and sets the REBATE column to10.3 Closes the PURCHASES table and releases the WRITE lock.Preventing a Hung <strong>SAS</strong> Session When Reading and Inserting to the SameTable/* <strong>SAS</strong>/<strong>ACCESS</strong> lock options prevent the session hang *//* that occurs when reading & inserting into the same table. */libname tra teradata user=testuser password=testpass connection=unique;proc sql;insert into tra.sametableselect * from tra.sametable(read_isolation_level=accessread_mode_wait=yesread_lock_type=table);Here is what <strong>SAS</strong>/<strong>ACCESS</strong> does in the above example:3 Creates a read connection to fetch the rows selected (SELECT *) fromTRA.SAMETABLE and specifies an <strong>ACCESS</strong> lock(READ_ISOLATION_LEVEL=<strong>ACCESS</strong>). Teradata grants the <strong>ACCESS</strong> lock.3 Creates an insert connection to Teradata to process the insert operation toTRA.SAMETABLE. Because the <strong>ACCESS</strong> lock that is already on the table permitsaccess to the table, Teradata grants a WRITE lock.

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

Saved successfully!

Ooh no, something went wrong!