The LIBNAME Statement for Relational Databases

DBCONINIT= LIBNAME Option



Specifies a user-defined initialization command to be executed immediately after every connection to the DBMS that is within the scope of the LIBNAME statement or libref
Valid in: the SAS/ACCESS LIBNAME statement
DBMS support: DB2 UNIX/PC, DB2 z/OS, HP Neoview, Informix, Microsoft SQL Server, MySQL, Netezza, ODBC, OLE DB, Oracle, Sybase, Teradata
Default value: none

Syntax
Syntax Description
Details
Examples
See Also

Syntax

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

Syntax Description

DBMS-user-command

is any valid command that can be executed by the SAS/ACCESS engine 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, then a disconnect 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.  [cautionend]


Examples

In the following 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;

In the following 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.


See Also

DBCONTERM= LIBNAME Option

space
Previous Page | Next Page | Top of Page