[Info-Ingres] Running Ingres SQL commands from a shell script?
Dan Stromberg
dstromberg at datallegro.com
Thu Apr 26 15:13:03 CDT 2007
Will the E_'s always be at the beginnnig of a line, at least? I'm not sure I want to say I can no longer fields that contain E_.
-----Original Message-----
From: andre.laframboise at lac-bac.gc.ca [mailto:andre.laframboise at lac-bac.gc.ca]
Sent: Thu 4/26/2007 2:37 PM
To: Dan Stromberg; Piotr.Wisniewski at psat.pl; info-ingres at kettleriverconsulting.com
Subject: RE: [Info-Ingres] Running Ingres SQL commands from a shell script?
Hi Dan,
The $? will be true because the Teminal monitor process itself was
successful (connected and ran the sql).
You want to scan the output for an error. You'll need to capture it and run
it through a filter (grep, awk, etc).
A grep for 'E_' should catch the errors unless you have db objets (tables,
columns) that start with E_.
Andre
_____
From: info-ingres-bounces at kettleriverconsulting.com on behalf of Dan
Stromberg
Sent: Thu 4/26/2007 1:30 PM
To: Wisniewski, Piotr, (ProService AT);
info-ingres at kettleriverconsulting.com
Subject: Re: [Info-Ingres] Running Ingres SQL commands from a shell script?
Add to that:
I intentionally constructed an SQL query that should give an error, but
dividing by zero, by when I exited the terminal monitor, return code to bash
("$?") was true - not false as I would've hoped.
I did see an E_ error code at the beginning of a line though. Can I grep
for "^E_" to see if there are errors? And if so, how certainly is it that
this will match all errors and only errors? EG, what if I had a table for a
ingres error codes - I don't want to mistakenly flag an error for any query
listing columns from it.
-----Original Message-----
From: "Wisniewski, Piotr, (ProService AT)" [mailto:Piotr.Wisniewski at psat.pl
<mailto:Piotr.Wisniewski at psat.pl> ]
Sent: Thu 4/26/2007 6:49 AM
To: Dan Stromberg; info-ingres at kettleriverconsulting.com
Subject: RE: [Info-Ingres] Running Ingres SQL commands from a shell script?
BTW,
I'd like to know when does the SQL command return nonzero exit status.
Recently I upgraded to Ingres 2006 Version II 9.0.4 (a64.sol/105)
and I noticed that sometimes the exit status is set to nonzero when certain
SQL errors occur when running the sql script. I recall in previous versions
such errors did not cause nonzero exit status. The exit status was always 0
unless some invocation error occurred like when running
sql db < non_existing_file
-----Original Message-----
From: Dan Stromberg [mailto:dstromberg at datallegro.com
<mailto:dstromberg at datallegro.com> ]
Sent: Thursday, April 26, 2007 3:33 AM
To: info-ingres at kettleriverconsulting.com
Subject: [Info-Ingres] Running Ingres SQL commands from a shell script?
Hi folks.
Is there any good way, from a shell script, to run SQL commands against
Ingres (perhaps via ingres' terminal monitor), and to get a useful exit
status from the SQL statements back to the calling shell?
I realize I could use something like python with an ODBC interface, but 1)
that seems kind of heavyweight for what I want to do and 2) I don't think
I'll be able to get permission to put an ODBC interface -on- the
machines in question. It's pretty much whatever comes with CentOS 4.4 or
not at all for this project.
Ideal might be to have any exit stati and'd or or'd together (dare I say,
at the caller's discretion?), or to have an array of exit stati kind of
like bash's $PIPESTATUS array, except for a chronology of statements, not
concurrent-but-chained-together statements.
If I must, I could run the SQL statements (the ones with side effects,
at least) one a time though.
Any suggestions?
Thanks!
_______________________________________________
Info-Ingres mailing list
Info-Ingres at kettleriverconsulting.com
http://www.kettleriverconsulting.com/mailman/listinfo/info-ingres
<http://www.kettleriverconsulting.com/mailman/listinfo/info-ingres>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.kettleriverconsulting.com/mailman/private/info-ingres/attachments/20070426/771ac64c/attachment-0001.html
More information about the Info-Ingres
mailing list