ALLBASE/SQL Reference Manual (36216-90216)

96 Chapter2
Using ALLBASE/SQL
Using Multiple Connections and Transactions with Timeouts
Connecting to DBEnvironments
With multi-connect functionality, you can specify a connection name each time you connect
to a DBEnvironment by means of one of the following statements:
CONNECT
START DBE
START DBE NEW
START DBE NEWLOG
For example, in ISQL, the following CONNECT statement establishes a connection to
PartsDBE and assigns a connection name for this connection:
isql=> CONNECT TO 'PartsDBE' AS 'Parts1';
In an application program, you can use either a string or, as in the following example, a
host variable:
CONNECT TO 'PartsDBE' AS :Parts1
The connection name is used when setting the current connection, as described in the next
section. It must be unique within an application and be assigned by means of either a
character host variable or a string literal.
Which of the above statements you choose for assigning the connection name depends on
the needs of your application. See Chapter 10 , “SQL Statements A - D,” and Chapters 11
and 12 for the complete syntax of each statement.
Setting the Current Connection
Within an application or ISQL, the current connection is set by the most recent statement
that connects to or sets the connection to a DBEnvironment. In order for a multi-connect
transaction to execute, the current connection must be set to the DBEnvironment in which
the transaction will execute.
To change the current connection within a set of connected DBEnvironments, use a SET
CONNECTION statement to specify the applicable connection name, as in the following
example for ISQL:
isql=> SET CONNECTION 'Parts1';
In an application program, you can use either a string literal or, as in the following
example, a host variable:
SET CONNECTION :Parts1
Remember, any SQL statement issued applies to the current connection.
NOTE
Following a RELEASE or DISCONNECT CURRENT command, there is no current
connection until a SET CONNECTION command is used to set the current
connection to another existing connection, or a new connection is established
by using the CONNECT, START DBE, START DBE NEW,orSTART DBE NEW LOG
commands.