DBLIBINIT= LIBNAME Statement Option

Specifies a user-defined initialization command to execute once within the scope of the LIBNAME statement or libref that established the first connection to the DBMS.

Valid in: SAS/ACCESS LIBNAME statement
Category: Data Set Control
Default: none
Data source: Amazon Redshift, Aster, DB2 under UNIX and PC Hosts, DB2 under z/OS, Greenplum, Hadoop, HAWQ, Impala, Informix, JDBC, Microsoft SQL Server, MySQL, Netezza, ODBC, OLE DB, Oracle, PostgreSQL, SAP ASE, SAP HANA, SAP IQ, Snowflake, Spark, Teradata, Vertica, Yellowbrick
Notes: Support for Spark was added in SAS 9.4M7.
Support for Yellowbrick was added in SAS 9.4M7.
See: CONNECTION= LIBNAME option, CONNECTION_GROUP= LIBNAME option, DBCONINIT= LIBNAME option, DBCONTERM= LIBNAME option, DBLIBTERM= LIBNAME option, DEFER= LIBNAME option

Syntax

DBLIBINIT=<'>DBMS-user-command<'>

Syntax Description

DBMS-user-command

any DBMS command that the SAS/ACCESS engine can execute and that does not return a result set or output parameters.

Details

The initialization command that you select can be a script, stored procedure, or any DBMS SQL statement that might provide additional control over the interaction between your SAS/ACCESS interface and the DBMS.

The command executes immediately after the first DBMS connection is successfully established. If the command fails, a disconnection occurs and the libref is not assigned. You must specify the command as a single quoted string unless it is an environment variable.

DBLIBINIT= fails if either CONNECTION=UNIQUE or DEFER=YES, or if both of these LIBNAME options are specified.

When multiple LIBNAME statements share a connection, the initialization command executes only for the first LIBNAME statement, immediately after the DBMS connection is established. (Multiple LIBNAME statements that use CONNECTION=GLOBALREAD and identical values for CONNECTION_GROUP=, DBCONINIT=, DBCONTERM=, DBLIBINIT=, and DBLIBTERM= options and any DBMS connection options can share the same connection to the DBMS.)

Example: Allow Only One LIBNAME Statement to Connect

In this example, CONNECTION=GLOBALREAD is specified in both LIBNAME statements, but the DBLIBINIT commands are different. Therefore, the second LIBNAME statement fails to share the same physical connection.

libname mydblib oracle user=myusr1 pass=mypwd1
   connection=globalread dblibinit='Test';
libname mydblib2 oracle user=myusr1 pass=mypwd1
   connection=globalread dblibinit='NoTest';
Last updated: February 3, 2026