Programming Guide



CONNECTION

Sets or changes the default connection

Synopsis

DBMS CONNECTION connection

Arguments

connection
Name of the connection to set as the default.

Description

If an application declares two or more connections, the application can set a default connection with DBMS CONNECTION. The default connection is used for all subsequent statements that do not use a WITH CONNECTION or WITH CURSOR clause.

Example

// con1 is set to be the default connection.
// The INSERT statement has a WITH CONNECTION clause
// using connection con2.
// The SELECT statement uses the default connection.
DBMS ENGINE sybase
DBMS DECLARE con1 CONNECTION FOR USER ":uname" \
PASSWORD ":pword" SERVER "s1" DATABASE "master"
DBMS DECLARE con2 CONNECTION FOR USER ":uname" \
PASSWORD ":pword" SERVER "s2" DATABASE "videobiz"
DBMS CONNECTION con1
DBMS WITH CONNECTION con2 DECLARE c1 CURSOR FOR \
INSERT INTO tapes (title_id, copy_num, status) \
VALUES (::title_id, ::copy_num, ::status)
DBMS WITH CURSOR c1 EXECUTE USING title_id, copy_num, status
DBMS SELECT title_id, name FROM titles

See Also

DECLARE CONNECTION, WITH CONNECTION, dm_is_connection