exit isql 
Author Message
 exit isql

I posted an article two weeks ago asking about exiting isql based on a
condition.   One followup article suggested using "return" instead of
"exit".  I tried it out.  It works fine for one batch.  But what I am
doing is to write a big isql script with many "go" in it.  My script need
to access a table which I'm not always sure that it will be there.  So
I would like to build in an error checking in my script.  If the desired
table is not in database, the script should quit immediately with an error
message.  That is, batches after my error-checking batch should not be executed.

Any suggestions of how to do that?

--

Vincent Q. Yin



Sun, 13 Aug 1995 02:48:28 GMT
 exit isql

 . . . . .

Quote:
> doing is to write a big isql script with many "go" in it.  My script need
> to access a table which I'm not always sure that it will be there.  So
> I would like to build in an error checking in my script.  If the desired
> table is not in database, the script should quit immediately with an error
> message.  That is, batches after my error-checking batch should not be executed.

Could you show us(again?) a list of some of the things you're trying to
do?  Have you looked at building a stored procedure, i.e., instead of
an isql script, put everything in a stored procedure . . . or maybe a
couple stored procedures.

For example, if you're looking for the availability of a table you
just look in the sysobjects table for the desired database and branch
within the sp accordingly(or return).  

Of course, you can't do any 'dynamic' programming in a stored procedure;
unless you wrote a . . say . .  'sed' script which modifies the sp file
definition, reloads the sp into the database, then executes said
sp . . .

. . . then again I may be getting too fancy or complicated for what you want to do??

Mark
--
Mark A. Parsons



Mon, 14 Aug 1995 23:01:00 GMT
 exit isql

Quote:


> . . . . .

>> doing is to write a big isql script with many "go" in it.  My script need
>> to access a table which I'm not always sure that it will be there.  So
>> I would like to build in an error checking in my script.  If the desired
>> table is not in database, the script should quit immediately with an error
>> message.  That is, batches after my error-checking batch should not be executed.

>Could you show us(again?) a list of some of the things you're trying to
>do?  Have you looked at building a stored procedure, i.e., instead of
>an isql script, put everything in a stored procedure . . . or maybe a
>couple stored procedures.

>For example, if you're looking for the availability of a table you
>just look in the sysobjects table for the desired database and branch
>within the sp accordingly(or return).  

>Of course, you can't do any 'dynamic' programming in a stored procedure;
>unless you wrote a . . say . .  'sed' script which modifies the sp file
>definition, reloads the sp into the database, then executes said
>sp . . .

>. . . then again I may be getting too fancy or complicated for what you want to do??

>Mark
>--
>Mark A. Parsons


Yes!  I finally figured out why I CAN'T use stored procedures. I need to create

rules and bind them to my tables.  However, CREATE RULE is not allowed in stored

procedures.  Plus, my script is more than 1000 lines long.  It makes me feel
very uncomfortable to make such a long stored procedure.

I appreciate your many articles, Mark.  And I think your suggestions are very
good ideas.  But I'm just too 'strange' here.  Can I exit based on a condition
in a long isql script with many go's ?

--

Vincent Q. Yin



Sat, 19 Aug 1995 01:06:25 GMT
 exit isql

Quote:

>Yes!  I finally figured out why I CAN'T use stored procedures. I need to
>create rules and bind them to my tables.  However, CREATE RULE is not
>allowed in stored procedures.

Well, then invoke isql twice. First to check if the crucial table exist,
and then for the real job. Make the decision on shell level. (Or get
sybperl :-)

Quote:
>Plus, my script is more than 1000 lines long.  It makes me feel
>very uncomfortable to make such a long stored procedure.

Not talking of how unconfortable the server will feel. :-) No good
excuse though, as you could always split in several procedures.

Quote:
>Can I exit based on a condition in a long isql script with many go's ?

I know no way to do so. But I'm not T-SQL guru. Then again is the shell
solution that terribly ugly?
--



Sat, 19 Aug 1995 03:13:16 GMT
 exit isql

Quote:

> (Or get sybperl :-)

Or, I might add, sybtcl.  I do almost all my DB programming in TCL and
TK.  Lots easier than C, and lots more flexible than trying to do
everything in SQL.  

--
=Spencer W. Thomas              |  Info Tech and Networking, B1911 CFOB, 0704
   "Genome Informatician"     |  Univ of Michigan, Ann Arbor, MI 48109



Sun, 20 Aug 1995 22:26:36 GMT
 exit isql
I had a query about sybtcl, but was unable to reply by e-mail.  So
here's the info.

Sybtcl is a code extension to Tcl/TclX/Tk that provides an interface
to dblib functions.  It allows you to submit SQL, retrieve the
results, read TEXT pages, and determine the status of your SQL
(errors, etc.).  It's available from the Tcl "contributed software"
site, which is now

        harbor.ecn.purdue.edu (128.46.128.76)
        /pub/tcl

The current version seems to be 1.2, which works with all the versions
of Tcl/TclX I've tried it with (up to Tcl 6.7/TclX 6.5c).  It doesn't
require TclX, but the installation instructions assume you've got it.

There is one bug I've found, for which I include the patch below.

I also have some TCL procs that (I think) make it slightly easier to
use, and I have a full-blown browser that lets you (more-or-less)
easily investigate database structure and contents (no, it doesn't
do E-R diagrams).

For those of you not familiar with TCL, it's an interpreted extensible
language that is designed for adding command language interface to
tools.  TK is an extension of TCL that provides an interface to X with
a Motif-like look & feel.  In my experience, I can produce "GUI"
programs in a fraction (orders of magnitude) of the time that would be
required to write them in C or another similar language.  See
comp.lang.tcl for more discussion, or look at the code and
documentation.  These are available from the archive site:

        sprite.berkeley.edu (128.32.150.27)
        /tcl

% diff -c sybtcl.c~ sybtcl.c
*** sybtcl.c~   Wed Oct  7 12:58:54 1992
--- sybtcl.c    Tue Nov 24 12:30:44 1992
***************
*** 155,162 ****
--- 155,164 ----
            sprintf(buf,"%d",oserr);
              Tcl_SetVar2(SybInterp,SybMsgArray,"oserr",buf,TCL_GLOBAL_ONLY);

+           if ( dberrstr == NULL ) dberrstr = "";
              Tcl_SetVar2(SybInterp,SybMsgArray,"dberrstr",dberrstr,
                        TCL_GLOBAL_ONLY);
+           if ( oserrstr == NULL ) oserrstr = "";
              Tcl_SetVar2(SybInterp,SybMsgArray,"oserrstr",oserrstr,
                        TCL_GLOBAL_ONLY);

--
=Spencer W. Thomas              |  Info Tech and Networking, B1911 CFOB, 0704
   "Genome Informatician"     |  Univ of Michigan, Ann Arbor, MI 48109



Fri, 25 Aug 1995 20:22:55 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. exit isql

2. "Isql: error converting exit value."

3. ISQL and EXIT Command

4. Isql: error converting exit value

5. conditionally exiting from an isql script

6. isql setting exit status for shell

7. ERROR exiting from isql script

8. isql with exit status

9. exiting from isql when cu to another machine

10. ISQL EXIT(...) returns: "Error converting exit value."

11. EXIT vs EXIT WHEN

12. Exiting Windows after you Exit Paradox


 
Powered by phpBB® Forum Software