Chapter Contents |
Previous |
Next |
LIBNAME Statement: ORACLE Specifics |
Valid: | Anywhere |
Syntax | |
Arguments | |
Details | |
SAS/ACCESS Engine Connection Options | |
SAS/ACCESS LIBNAME Options | |
Example: Specifying a LIBNAME Statement to Access ORACLE Data |
Syntax |
LIBNAME librefSAS/ACCESS-engine-name <SAS/ACCESS-engine-connection-options> <SAS/ACCESS-LIBNAME-options>; |
oracleSAS/ACCESS engines are implemented differently in different operating environments. The engine name is required.
Some SAS/ACCESS LIBNAME options have the same names as SAS/ACCESS data set options. When you specify an option in the LIBNAME statement, it applies to objects and data that are referenced by the libref. A SAS/ACCESS data set option applies only to the data set on which it is specified. If a like-named option is specified in both the SAS/ACCESS engine LIBNAME statement and after a data set name (which references a DBMS table or view), the SAS System uses the value that is specified later, on the data set name. See Data Set Options: ORACLE Specifics for more information.
Details |
The LIBNAME statement associates a libref with a SAS/ACCESS engine to access tables or views in a database management system (DBMS). The SAS/ACCESS engine enables you to connect to a particular DBMS and to specify a DBMS table or view name in a two-level SAS name.
For example, in MYDBLIB.EMPLOYEES_Q2, MYDBLIB is a SAS libref that points to a particular group of DBMS objects, and EMPLOYEES_Q2 is a DBMS table name in the default schema. When you specify MYDBLIB.EMPLOYEES_Q2 in a DATA step or procedure, you dynamically access the DBMS table. Beginning in Version 7, SAS software supports reading, updating, creating, and deleting DBMS tables dynamically.
To disassociate or clear a libref from a DBMS, use a LIBNAME statement, specifying the libref (for example, MYDBLIB) and the CLEAR options as follows:
libname mydblib CLEAR;The database engine will disconnect from the database and close any free threads or resources that are associated with that connection.
SAS/ACCESS Engine Connection Options |
The SAS/ACCESS engine connection options for ORACLE are as follows:
USER= | |
PASSWORD= | |
PATH= |
USER= can also be specified with the USERNAME= alias.
PASSWORD= can also be specified with the PW=, PASS=, ORACLEPW=, and ORAPW= aliases.
SAS/ACCESS uses the same ORACLE path designation that you use to connect to ORACLE directly. See your database administrator to determine the databases that have been set up in your operating environment, and to determine the default values if you do not specify a database. On UNIX systems, the TWO_TASK environment variable is used, if set. If neither PATH= nor TWO_TASK have been set, the default value is the local driver.
SAS/ACCESS LIBNAME Options |
The SAS/ACCESS interface to ORACLE supports all of the SAS/ACCESS LIBNAME options listed in SAS/ACCESS LIBNAME Options. In addition to the supported options, the following LIBNAME options are used only in the interface to ORACLE or have ORACLE-specific aspects to them:
If you omit DBINDEX=, the default value is DBINDEX=NO.
For a full description of this option, refer to the LIBNAME option, DBINDEX=.
If you omit DBLINK=, SAS accesses objects in the local database.
A link is a database object that is used to identify an object stored in a remote database. A link contains stored path information and may also contain user name and password information for connecting to the remote database.
If you omit DBPROMPT=, the default value is DBPROMPT=NO. The SAS/ACCESS Interface to ORACLE allows you to enter 30 characters for the USERNAME and PASSWORD and up to 70 characters for the PATH, depending on your platform.
For a full description of this option, refer to the LIBNAME option, DBPROMPT= .
If you omit INSERTBUFF=, the default value is INSERTBUFF=10. SAS allows the maximum number that is allowed by ORACLE.
Note: When you assign a value that is greater than
INSERTBUFF=1, the SAS application notes that indicate the success or failure
of the insert operation may be incorrect because these notes only represent
information for a single insert, even when multiple inserts are performed.
Note: If specified,
the value of the DBCOMMIT= option overrides the value of
INSERTBUFF=.
If you specify LOCKWAIT=YES, SAS waits until rows are available for locking. If you specify LOCKWAIT=NO, SAS does not wait and returns an error to indicate that the lock is not available. If you omit LOCKWAIT=, the default value is LOCKWAIT=YES.
If you specify ORACLE_73_OR_ABOVE=YES or omit this option, SAS can use the SERIALIZABLE isolation level for update locking that is available in ORACLE 7.3 and above. Users with version 7.3 or above may set the ORACLE_73_OR_ABOVE= option to either YES or NO.
For Oracle versions prior to 7.3, updates without locking are performed as they were in SAS Version 6. In Version 6, a row is updated with an additional WHERE clause to ensure that the row has not changed since the time it was read. The update fails if the row has changed. For versions 7.3 and above, updates are performed in serializable transactions. An update on a row automatically fails if the row has been changed since the time the serializable transaction started. (This is not always true; due to current, published ORACLE bug 440366, sometimes an update on a row fails even if the row has not changed. ORACLE offers the following solution: When creating a table, users can increase the number of INITRANS to at least 3 for the table.)
In a scenario where ORACLE_73_OR_ABOVE= is incorrectly set to YES when it should be NO, the Oracle engine detects this error and automatically makes the assumption that the Oracle version is below 7.3. In a scenario where ORACLE_73_OR_ABOVE= is incorrectly set to NO when it should be YES, the Oracle engine does not detect the incorrect setting. The update is performed without using a serializable transaction.
The advantages of setting ORACLE_73_OR_ABOVE=YES are that no extra WHERE clause overhead is incurred, and WHERE clause floating point number comparison problems (precision problems) are avoided.
ORACLE_73_OR_ABOVE= can also be specified with the ORACLE_73= alias.
See also READ_ISOLATION_LEVEL=, UPDATE_ISOLATION_LEVEL=.
If you omit PRESERVE_COL_NAMES=, the default value is PRESERVE_COL_NAMES=NO. If you want to preserve the case or allow characters that are not supported in SAS names, such as '$', in your column names, set PRESERVE_COL_NAMES=YES.
For a full description of this option, refer to the LIBNAME option, PRESERVE_COL_NAMES=.
If you omit PRESERVE_TAB_NAMES=, the default value is PRESERVE_TAB_NAMES=NO. If you want to preserve case or allow characters that are not supported in SAS names, such as '$', in your object names, including table names, schema names, and link names, set PRESERVE_TAB_NAMES=YES.
For a full description of this option, refer to the LIBNAME option, PRESERVE_TAB_NAMES=.
If you are using ORACLE Version 7.3 or later, you can set READ_ISOLATION_LEVEL= to READCOMMITTED or SERIALIZABLE. If you specify READ_ISOLATION_LEVEL=READCOMMITTED, SAS uses the standard method of read locking that is available in all ORACLE versions. If you specify READ_ISOLATION_LEVEL=SERIALIZABLE, SAS uses the SERIALIZABLE method of read locking that is available in ORACLE versions 7.3 and later. The ORACLE_73= option must be set to ORACLE_73=YES to use the SERIALIZABLE isolation level.
The SPOOL= option overrides the READ_ISOLATION_LEVEL= option. If SPOOL=DBMS, SAS automatically sets READ_ISOLATION_LEVEL=SERIALIZABLE for ORACLE 7.3 or later and to READ_ONLY for prior versions. If you omit READ_ISOLATION_LEVEL=, the default value is based on the value of the SPOOL= option. In all other cases, the default value is READCOMMITTED.
When READ_ISOLATION_LEVEL is set to SERIALIZABLE, the CONNECTION option must be set to UNIQUE. If not, an error occurs.
Note: This option should be rarely
needed because the SAS/ACCESS engine
chooses the appropriate isolation level based on other locking options.
See also UPDATE_ISOLATION_LEVEL=.
If you omit READ_LOCK_TYPE=, the default value is READ_LOCK_TYPE=NOLOCK. If you specify READ_LOCK_TYPE=NOLOCK, table locking is not used during the reading of tables and views. If you specify READ_LOCK_TYPE=ROW, the ORACLE "ROW SHARE" table lock is used during the reading of tables and views. If you specify READ_LOCK_TYPE=TABLE, the ORACLE "SHARE" table lock is used during the reading of tables and views.
When READLOCK_TYPE is set to either TABLE or ROW, the CONNECTION option must be set to UNIQUE. If not, an error occurs.
For a full description of this option, refer to the LIBNAME option, READ_LOCK_TYPE.
If you omit READBUFF=, the default value is READBUFF=25. SAS allows the maximum number that is allowed by ORACLE.
READBUFF= can also be specified with the BUFFSIZE= alias.
If you omit SCHEMA=, SAS accesses objects in the default and public schemas. If PRESERVE_TAB_NAMES=NO, SAS converts the SCHEMA= value to uppercase because all values in the ORACLE data dictionary are uppercase unless quoted.
Instead of submitting PROC DATASETS, you can click on the libref for the SAS Explorer window to get this same information.
If you omit SPOOL=, the default value is SPOOL=YES. If SPOOL=DBMS, the SAS/ACCESS Interface to ORACLE satisfies the two-pass requirement by starting a read-only transaction. SPOOL=YES and SPOOL=DBMS have comparable performance results for ORACLE; however, SPOOL=DBMS does not use any disk space.
When SPOOL is set to DBMS, the CONNECTION option must be set to UNIQUE. If not, an error occurs.
For a full description of this option, refer to the LIBNAME option, SPOOL=.
If you are using ORACLE Version 7.3 or later, you can set UPDATE_ISOLATION_LEVEL to READCOMMITTED or SERIALIZABLE. If you specify UPDATE_ISOLATION_LEVEL=READCOMMITTED, SAS uses the standard method of update locking that is available in all ORACLE versions. If you specify UPDATE_ISOLATION_LEVEL=SERIALIZABLE, SAS uses the SERIALIZABLE method of update locking that is available in ORACLE versions 7.3 and later. The ORACLE_73 option must be set to ORACLE_73=YES to use the SERIALIZABLE isolation level.
If you omit UPDATE_ISOLATION_LEVEL=, the default value is based on the value of the UPDATE_LOCK_TYPE= option. If UPDATE_LOCK_TYPE=NOLOCK, SAS automatically sets UPDATE_ISOLATION_LEVEL=SERIALIZABLE for ORACLE 7.3 or later and READ_ONLY for prior versions. In all other cases, the default value is READCOMMITTED.
Note: This option should be rarely
needed because the SAS/ACCESS engine
chooses the appropriate isolation level based on other locking options.
If you omit UDPATE_LOCK_TYPE, the default value is UPDATE_LOCK_TYPE=NOLOCK. If you specify UPDATE_LOCK_TYPE=NOLOCK, table locking is not used during the reading of tables and views for update. If you specify UPDATE_LOCK_TYPE=ROW, the ORACLE "ROW SHARE" table lock is used during the reading of tables and views for update. If you specify UPDATE_LOCK_TYPE=TABLE, the ORACLE "EXCLUSIVE" table lock is used during the reading of tables and views for update.
If UPDATE_LOCK_TYPE=NOLOCK and ORACLE_73=YES, updates are performed using serializable transactions. If UPDATE_LOCK_TYPE=NOLOCK and ORACLE_73=NO, updates are performed using an extra WHERE clause to ensure that the row has not been updated since it was first read. Updates might fail when UPDATE_LOCK_TYPE=NOLOCK because other users might modify a row after the row was read for update.
If the ORACLE_73_OR_ABOVE= option is incorrectly set to YES (meaning that the Oracle server version is below 7.3), the Oracle engine detects this, and the update is performed as if ORACLE_73_OR_ABOVE= were correctly set.
For a full description of this option, refer to the LIBNAME option, UPDATE_LOCK_TYPE=.
If you omit UPDATEBUFF=, the default value is UPDATEBUFF=1. SAS allows the maximum that ORACLE allows.
Example: Specifying a LIBNAME Statement to Access ORACLE Data |
libname mydblib oracle user=scott password=tiger path='hrdept_002'; proc print data=mydblib.employees; where dept='CSR010'; run;
To access an ORACLE object in another schema, use the SCHEMA= option as in the following example. The schema name is typically a person's user name or ID.
libname mydblib oracle user=gona password=twins path='hrdept_002' schema=john; proc sql; select * from mydblib.superv where jobcat='BC';
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.