cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get SET CONNECTION to switch to a previous connection in dbisql 12.0.1?

Breck_Carter
Participant
948

According to http://dcx.sybase.com/index.html#1201en/dbreference/connect-statement.html the CONNECT AS statement allows switching between open connections in ISQL. It does appear to work OK in dbisqlc, but in dbisql the previous differently-named connections appear to be closed when a new CONNECT AS statement is executed.

CONNECT TO ddd1 DATABASE ddd1 AS ddd1 USER dba IDENTIFIED BY sql;
CREATE TABLE t ( pkey INTEGER NOT NULL PRIMARY KEY );
INSERT t VALUES ( 1 );
COMMIT;
SELECT * FROM t;

CONNECT TO ddd2 DATABASE ddd2 AS ddd2 USER dba IDENTIFIED BY sql;
CREATE TABLE t ( pkey INTEGER NOT NULL PRIMARY KEY );
INSERT t VALUES ( 2 );
COMMIT;
SELECT * FROM t;

CONNECT TO ddd3 DATABASE ddd3 AS ddd3 USER dba IDENTIFIED BY sql;
CREATE TABLE t ( pkey INTEGER NOT NULL PRIMARY KEY );
INSERT t VALUES ( 3 );
COMMIT;
SELECT * FROM t;

SET CONNECTION ddd1;
SELECT * FROM t;

SET CONNECTION ddd2;
SELECT * FROM t;

SET CONNECTION ddd3;
SELECT * FROM t;

Everything works as expected with dbisqlc: the three SET CONNECTION statements cause the three SELECTs to display 1, 2 and 3 from the three different databases.

However, in dbisql the first SET CONNECTION raises this error:

Unknown connection "ddd1".
Line 1, column 16
You can continue executing or stop.

SET CONNECTION ddd1

My records show this behavior exists in V10 and V11 as well... I've been trying to write a blog post about switching connections for that long 🙂

Accepted Solutions (0)

Answers (0)