Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

READ Statement issue within IF THEN ELSE END IF in Interactive SQL

324 views
Skip to first unread message

Rachan Terrell

unread,
Feb 18, 2009, 12:18:54 PM2/18/09
to
ASA Version 10.0.1.3784

We created a file call TESTREAD.SQL which contains only one statement:

SELECT 1 AS Col_Name FROM DUMMY;

In the Interactive SQL we were able to execute this statement:

READ C:\TEMP\TESTREAD.SQL

Which return:

Col_Name
1

No problem here.....But when we included IF...THEN...ELSE...ENDIF

IF (@@SERVERNAME = @@SERVERNAME) THEN
READ C:\TEMP\TESTREAD.SQL
ELSE
READ C:\TEMP\TESTREAD.SQL
END IF;

We got this error:

Could not execute statement.
Syntax error near 'READ' on line 2
SQLCODE=-131, ODBC 3 State="42000"
Line 1, column 1

Any help in this matter is truly appreciative.

Best regards,
Rachan Terrell

Reg Domaratzki [Sybase iAnywhere]

unread,
Feb 18, 2009, 12:37:34 PM2/18/09
to
"Rachan Terrell" <web2...@hotmail.com> wrote in news:499c42fe$1@forums-
1-dub:

READ is an Interactive SQL command. As soon as you start using the
IF...THEN...ELSE...ENDIF syntax, you have created a batch statement which
is executed directly by the database engine. The database engine has
no knowledge of the READ command, so you get the error "syntax error near
read" that you are seeing.

--
Reg Domaratzki, Sybase iAnywhere Solutions
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Docs : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swd/base.do
-> Choose SQL Anywhere Studio
-> Set filter to "Display ALL platforms IN ALL MONTHS"

Rachan Terrell

unread,
Feb 18, 2009, 12:55:12 PM2/18/09
to
Reg,

Thank for your help.

Best regards,
Rachan Terrell
"Reg Domaratzki [Sybase iAnywhere]" <FirstName...@ianywhere.com> wrote
in message news:Xns9BB6807A454BC...@10.22.241.106...

Breck Carter [TeamSybase]

unread,
Feb 19, 2009, 4:41:43 PM2/19/09
to
I think there has been some talk about conditional parsing for
dbisql... I know that I would love it!

With some effort you can do some interesting things with nested *.sql
files and PARAMETERS substitution.

If you tell us what you are trying to accomplish, perhaps someone will
have an idea... start a new thread, not a reply to this one.

Breck

On 18 Feb 2009 09:18:54 -0800, "Rachan Terrell" <web2...@hotmail.com>
wrote:

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck....@risingroad.com

0 new messages