Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

ISQL, how to abort script?

5 posts in General Discussion Last posting was on 2010-09-21 22:06:20.0Z
George Brink Posted on 2010-09-21 16:01:22.0Z
From: George Brink <siberianowl@yahoo.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: ISQL, how to abort script?
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c98d6d2$1@forums-1-dub>
Date: 21 Sep 2010 09:01:22 -0700
X-Trace: forums-1-dub 1285084882 10.22.241.152 (21 Sep 2010 09:01:22 -0700)
X-Original-Trace: 21 Sep 2010 09:01:22 -0700, vip152.sybase.com
Lines: 23
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29578
Article PK: 78812

According to documentation:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1502/html/commands/BABDEBIA.htm
ISQL should stop if it encounter exit, quit, or bye keyword.
I tried to use it like this:
---- my.sql
if suser_name()<>'teamA'
begin
print 'Error! Only teamA allowed to use this script'
exit
end
go
-- some DDL commands
------------
and run this script like this:
isql -S... -U... -P... -imy.sql
But instead of the message and exit I am getting an error:
Incorrect syntax near the keyword 'exit'.

What am I doing wrong?
C:\>isql -v
Sybase CTISQL Utility/15.5/P-EBF17949 ESD #5/PC
Intel/BUILD1550-007/OPT/Tue May 25 00:45:29 2010


Jason L. Froebe [TeamSybase] Posted on 2010-09-21 16:29:16.0Z
From: "Jason L. Froebe [TeamSybase]" <jason.froebe@gmail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: ISQL, how to abort script?
References: <4c98d6d2$1@forums-1-dub>
In-Reply-To: <4c98d6d2$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c98dd5c@forums-1-dub>
Date: 21 Sep 2010 09:29:16 -0700
X-Trace: forums-1-dub 1285086556 10.22.241.152 (21 Sep 2010 09:29:16 -0700)
X-Original-Trace: 21 Sep 2010 09:29:16 -0700, vip152.sybase.com
Lines: 41
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29579
Article PK: 78808


On 9/21/2010 11:01 AM, George Brink wrote:
> According to documentation:
>
> http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1502/html/commands/BABDEBIA.htm
>
> ISQL should stop if it encounter exit, quit, or bye keyword.
> I tried to use it like this:
> ---- my.sql
> if suser_name()<>'teamA'
> begin
> print 'Error! Only teamA allowed to use this script'
> exit
> end
> go
> -- some DDL commands
> ------------
> and run this script like this:
> isql -S... -U... -P... -imy.sql
> But instead of the message and exit I am getting an error:
> Incorrect syntax near the keyword 'exit'.
>
> What am I doing wrong?
> C:\>isql -v
> Sybase CTISQL Utility/15.5/P-EBF17949 ESD #5/PC
> Intel/BUILD1550-007/OPT/Tue May 25 00:45:29 2010

"exit" isn't a T-SQL command. It is an isql command.

So, you would want to rewrite your script (this is just one way to do it):

> if suser_name()<>'teamA'
> begin
> print 'Error! Only teamA allowed to use this script'
> goto EXIT_HERE
> end
> else
> ** do something else
> EXIT_HERE:
> go

jason


George Brink Posted on 2010-09-21 16:44:02.0Z
From: George Brink <siberianowl@yahoo.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: ISQL, how to abort script?
References: <4c98d6d2$1@forums-1-dub> <4c98dd5c@forums-1-dub>
In-Reply-To: <4c98dd5c@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c98e0d2$1@forums-1-dub>
Date: 21 Sep 2010 09:44:02 -0700
X-Trace: forums-1-dub 1285087442 10.22.241.152 (21 Sep 2010 09:44:02 -0700)
X-Original-Trace: 21 Sep 2010 09:44:02 -0700, vip152.sybase.com
Lines: 57
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29580
Article PK: 78809

oh... I see. Since it is an ISQL's own command it can not be inside
'begin/end' block, or inside 'if' or basically anywhere in the batch
with a normal sql statements...
EXIT works only if it is located in its own batch.

Ok.... Back to the drawing board.
Probably raiserror can help?

My goal is to ensure that if table or procedure is modified or recreated
it would be owned by a specific group (field loginame in sysobjects).
The problem of permission inheritance across several databases...
How do people do it?

On 9/21/2010 12:29 PM, Jason L. Froebe [TeamSybase] wrote:
> On 9/21/2010 11:01 AM, George Brink wrote:
>> According to documentation:
>>
>> http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1502/html/commands/BABDEBIA.htm
>>
>>
>> ISQL should stop if it encounter exit, quit, or bye keyword.
>> I tried to use it like this:
>> ---- my.sql
>> if suser_name()<>'teamA'
>> begin
>> print 'Error! Only teamA allowed to use this script'
>> exit
>> end
>> go
>> -- some DDL commands
>> ------------
>> and run this script like this:
>> isql -S... -U... -P... -imy.sql
>> But instead of the message and exit I am getting an error:
>> Incorrect syntax near the keyword 'exit'.
>>
>> What am I doing wrong?
>> C:\>isql -v
>> Sybase CTISQL Utility/15.5/P-EBF17949 ESD #5/PC
>> Intel/BUILD1550-007/OPT/Tue May 25 00:45:29 2010
>
> "exit" isn't a T-SQL command. It is an isql command.
>
> So, you would want to rewrite your script (this is just one way to do it):
>
> > if suser_name()<>'teamA'
> > begin
> > print 'Error! Only teamA allowed to use this script'
> > goto EXIT_HERE
> > end
> > else
> > ** do something else
> > EXIT_HERE:
> > go
>
> jason


Bret Halford Posted on 2010-09-21 17:13:30.0Z
From: Bret Halford <bret@sybase.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: ISQL, how to abort script?
References: <4c98d6d2$1@forums-1-dub> <4c98dd5c@forums-1-dub> <4c98e0d2$1@forums-1-dub>
In-Reply-To: <4c98e0d2$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c98e7ba$1@forums-1-dub>
Date: 21 Sep 2010 10:13:30 -0700
X-Trace: forums-1-dub 1285089210 10.22.241.152 (21 Sep 2010 10:13:30 -0700)
X-Original-Trace: 21 Sep 2010 10:13:30 -0700, vip152.sybase.com
Lines: 11
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29581
Article PK: 78810


On 9/21/2010 10:44 AM, George Brink wrote:
> oh... I see. Since it is an ISQL's own command it can not be inside
> 'begin/end' block, or inside 'if' or basically anywhere in the batch
> with a normal sql statements...
> EXIT works only if it is located in its own batch.
>
> Ok.... Back to the drawing board.
> Probably raiserror can help?

Perhaps "select syb_quit()" will do.


Paul Dow <Paul.Dow Posted on 2010-09-21 22:06:20.0Z
Message-ID: <4C992C5B.3060507@sybase_dot.com>
From: Paul Dow <Paul.Dow@sybase_dot.com>
Organization: Sybase Engineering/iMET
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Lightning/1.0b2 Thunderbird/3.1.4
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
To: Bret Halford <bret@sybase.com>
Subject: Re: ISQL, how to abort script?
References: <4c98d6d2$1@forums-1-dub> <4c98dd5c@forums-1-dub> <4c98e0d2$1@forums-1-dub> <4c98e7ba$1@forums-1-dub>
In-Reply-To: <4c98e7ba$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 21 Sep 2010 15:06:20 -0700
X-Trace: forums-1-dub 1285106780 10.22.241.152 (21 Sep 2010 15:06:20 -0700)
X-Original-Trace: 21 Sep 2010 15:06:20 -0700, vip152.sybase.com
Lines: 19
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29586
Article PK: 78816

The answer to the Jan 2010 Quiz Question on Rob's http://www.sypron.nl/quiz.html
may be handy as an example.

- Paul.

On 21/09/2010 18:13, Bret Halford wrote:
> On 9/21/2010 10:44 AM, George Brink wrote:
>> oh... I see. Since it is an ISQL's own command it can not be inside
>> 'begin/end' block, or inside 'if' or basically anywhere in the batch
>> with a normal sql statements...
>> EXIT works only if it is located in its own batch.
>>
>> Ok.... Back to the drawing board.
>> Probably raiserror can help?
>
>
> Perhaps "select syb_quit()" will do.