DBLIBTERM= LIBNAME Statement Option

Specifies a user-defined termination command to execute once, before the DBMS that is associated with the first connection made by the LIBNAME statement or libref disconnects.

Valid in: SAS/ACCESS LIBNAME statement
Category: Data Set Control
Default: none
Interaction: DBLIBTERM= fails if either CONNECTION=UNIQUE or DEFER=YES, or if both of these LIBNAME options are specified.
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, DBLIBINIT= LIBNAME option, DEFER= LIBNAME option

Syntax

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

Syntax Description

DBMS-user-command

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

Details

The termination command that you select can be a script, stored procedure, or any DBMS SQL statement that might provide additional control over the interaction between the SAS/ACCESS engine and the DBMS. The command executes immediately before SAS terminates the last connection to the DBMS. If the command fails, SAS provides a warning message, but unassigning the library and disconnecting from the DBMS still occur. You must specify the command as a single quoted string.

When two LIBNAME statements share the same physical connection, the termination command is executed only once. 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 DBLIBTERM commands are different. Therefore, the second LIBNAME statement fails to share the same physical connection.

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