Unix Technical Forum

Can you do this in MySQL 4.1 scripting?

This is a discussion on Can you do this in MySQL 4.1 scripting? within the MySQL forums, part of the Database Server Software category; --> Is it possible to catch an error in 4.1 scripting? I have found that whan I run a script ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:00 AM
Sam Smith
 
Posts: n/a
Default Can you do this in MySQL 4.1 scripting?

Is it possible to catch an error in 4.1 scripting? I have found that whan I
run a script and a line of the script cannot find a table - instead of
halting
the script continues to run.

Is there anyway to get MySQL to halt the running of a script if an error
occurs in one line?

It's a little like the whole system is running with the VB 'on error resume
next' running all of the time.

Thank you for your help.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:00 AM
Willem Bogaerts
 
Posts: n/a
Default Re: Can you do this in MySQL 4.1 scripting?

> Is it possible to catch an error in 4.1 scripting? I have found that whan I
> run a script and a line of the script cannot find a table - instead of
> halting
> the script continues to run.


Funny question. MySQL does not support multiple queries, so the only one
that is aborted is all there is to abort. If you keep sending it queries
without checking for errors, you specifically _ask_ it to ignore the
errors. The aborted query is aborted as a whole. Every query is an
all-or-nothing command.

If you mean running a file in the mysql command-line client, it should
not continue unless you specify the --force option.

Best regards
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:09 AM
Sam Smith
 
Posts: n/a
Default Re: Can you do this in MySQL 4.1 scripting?

"Willem Bogaerts" <w.bogaerts@kratz.maardanzonderditstuk.nl> wrote in
message news:45b76d23$0$328$e4fe514c@news.xs4all.nl...
>> Is it possible to catch an error in 4.1 scripting? I have found that whan
>> I
>> run a script and a line of the script cannot find a table - instead of
>> halting
>> the script continues to run.

>
> Funny question. MySQL does not support multiple queries, so the only one


Not really. If I have a multiple list of commands in a script and one of
those lines errors (perhaps the table doesn't exist etc.) then I would
expect the whole script to stop running. It doesn't do this - it carries on
regardless.

Sort of basic expectation of what a set of code should do really.

---
Sam


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:10 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Can you do this in MySQL 4.1 scripting?

On Wed, 14 Feb 2007 11:19:37 -0000, Sam Smith wrote:
> "Willem Bogaerts" <w.bogaerts@kratz.maardanzonderditstuk.nl> wrote in
> message news:45b76d23$0$328$e4fe514c@news.xs4all.nl...
>>> Is it possible to catch an error in 4.1 scripting? I have found that whan
>>> I
>>> run a script and a line of the script cannot find a table - instead of
>>> halting
>>> the script continues to run.

>>
>> Funny question. MySQL does not support multiple queries, so the only one

>
> Not really. If I have a multiple list of commands in a script and one of
> those lines errors (perhaps the table doesn't exist etc.) then I would
> expect the whole script to stop running. It doesn't do this - it carries on
> regardless.
>
> Sort of basic expectation of what a set of code should do really.


But mostly mysql "script" are (effectively) typed commands from a
redirected standard input, using the same CLI as is used for a great
many other things. Stopping would require writing at least a gizmo that
sat between the redirect and watched for errors and threw away the rest
of the input after parsing an error response back from the CLI, OR
chaning the CLI so that it seizes up after the first error, which would
be inconvenient for interactive operation.

Basically, the CLI isn't *wrong*, it's just not doing what you'd like it
to do. So write a parser in expect, perl or php, or whatever language
you like, and watch for errors. It's not that tricky.

--
Judging by this particular thread, many people in this group spent their
school years taking illogical, pointless orders from morons and having
their will to live systematically crushed. And people say school doesn't
prepare kids for the real world. -- Rayner, in the Monastery
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:43 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com