Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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 :)

asked 10 Mar '11, 12:48

Breck%20Carter's gravatar image

Breck Carter
32.5k5417261050
accept rate: 20%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×106

question asked: 10 Mar '11, 12:48

question was seen: 824 times

last updated: 10 Mar '11, 12:48