Programming Guide



WITH CONNECTION

Uses a named connection for the duration of a statement

Synopsis

DBMS WITH CONNECTION connection DBMSstatement...

Arguments

WITH CONNECTION connection
Specifies connection for the execution of the command, overriding the default connection. connection must be declared and open. Colon expansion on the connection name is allowed.

DBMSstatement
Text of the DBMS command.

Description

The most frequent use of the DBMS WITH CONNECTION clause is in a DECLARE CURSOR statement.

DBMS WITH CONNECTION connection DECLARE cursor CURSOR...

Once a cursor is declared it remains associated with the connection on which it was declared. After declaring the cursor, the DBMS WITH CONNECTION clause must not be used in statements that manipulate the cursor. However, the DBMS WITH CONNECTION clause can be used on statements that manipulate the default cursor on any declared connection. Therefore, the following commands

DBMS WITH CONNECTION connection ALIAS ...
DBMS WITH CONNECTION connection CATQUERY ...
DBMS WITH CONNECTION connection CLOSE CURSOR
DBMS WITH CONNECTION connection COLUMN_NAMES
DBMS WITH CONNECTION connection CONTINUE
DBMS WITH CONNECTION connection CONTINUE_BOTTOM
DBMS WITH CONNECTION connection CONTINUE_TOP
DBMS WITH CONNECTION connection CONTINUE_UP
DBMS WITH CONNECTION connection FORMAT ...
DBMS WITH CONNECTION connection OCCUR ...
DBMS WITH CONNECTION connection QUERY ...
DBMS WITH CONNECTION connection RUN ...
DBMS WITH CONNECTION connection SQL ...
DBMS WITH CONNECTION connection START ...
DBMS WITH CONNECTION connection STORE ...
DBMS WITH CONNECTION connection UNIQUE ...

perform the request on the default SELECT cursor on the named connection.

Some engine-specific DBMS commands can also support the WITH CONNECTION clause. For more information, refer to "Database Drivers."

Example

// This procedure performs a commit before closing the 
// connection.
proc cleanup (connection)
DBMS WITH CONNECTION :connection COMMIT
DBMS CLOSE CONNECTION :connection
return 0

See Also

DECLARE CONNECTION, dm_is_connection