DBLIBTERM= LIBNAME Statement Option

Specifies a valid data source command to be executed once, before the data source that is associated with the last connection made by the LIBNAME statement or libref disconnects.
Valid in: LIBNAME statement
Default: none
Supports: All

Syntax

DBLIBTERM=< '> command<'>

Syntax Description

command
is any SQL or DataFlux FedSQL language statement, DBMS script, stored procedure, or native DBMS command that is supported by the driver. The command must not return a result set.

Details

The termination command that you select can be a script, stored procedure, or any DataFlux FedSQL language or DBMS SQL statement that might provide additional control over the interaction between the engine and the data source. The command executes immediately before SAS terminates the last connection to the data source. If the command fails, a warning message is issued but the library deassignment and disconnect still occurs. You must specify the command as a single, quoted string.
DBLIBTERM= fails if CONNECTION=UNIQUE or DEFER=YES is specified.

Example: Insert a Row After a Library is Cleared

In this example, Row 2 is added after the library has been cleared.
libname mydblib fedsvr server="d1234.us.company.com" 
   port=2171 user=user1 pwd=pass1   
   dsn=basedsn1;

data mydblib.mytab;
   x=1; y='one';
run;

libname mydblib fedsvr server="d1234.us.company.com" 
   port=2171 user=user1 pwd=pass1   
   dsn=basedsn1 
   dblibterm="insert into mytab values (2, 'two')";

libname mydblib clear;
libname mydblib fedsvr server="d1234.us.company.com" 
   port=2171 user=user1 pwd=pass1
   dsn=basedsn1;

proc sql;
   select * from mydblib.mytab;
quit;