DBCONINIT= LIBNAME Option

Specifies a user-defined initialization command to execute immediately after every connection to the DBMS that is within the scope of the LIBNAME statement or libref.
Valid in: SAS/ACCESS LIBNAME statement
Default: none
Data source: Aster nCluster, DB2 under UNIX and PC Hosts, DB2 under z/OS, Greenplum, HP Neoview, Informix, Microsoft SQL Server, MySQL, Netezza, ODBC, OLE DB, Oracle, Sybase, Sybase IQ, Teradata
See: DBCONTERM= LIBNAME option

Syntax

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

Syntax Description

DBMS-user-command
any valid 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 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 each 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.
Note: The initialization command might execute more than once because one LIBNAME statement might have multiple connections (for example, one for reading and one for updating).

Examples

Example 1: Apply the SET Statement to Every Connection

In this example, the DBCONINIT= option causes the DBMS to apply the SET statement to every connection that uses the MYDBLIB libref.
libname mydblib db2
        dbconinit="SET CURRENT SQLID='myauthid'";
proc sql;
   select * from mydblib.customers;
   insert into mydblib.customers
     values('33129804', 'VA', '22809', 'USA',
            '540/545-1400', 'BENNETT SUPPLIES', 'M. JONES',
            '2199 LAUREL ST', 'ELKTON', '22APR97'd);
   update mydblib.invoices
    set amtbill = amtbill*1.10
    where country = 'USA';
quit;

Example 2: Pass a Stored Procedure

In this example, a stored procedure is passed to DBCONINIT=.
libname mydblib oracle user=testuser pass=testpass
        dbconinit="begin dept_test(1001,25)";
end;
The SAS/ACCESS engine retrieves the stored procedure and executes it.