[Info-Ingres] Running Ingres SQL commands from a shell script?

Dan Stromberg dstromberg at datallegro.com
Thu Apr 26 12:30:32 CDT 2007


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]
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] 
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.kettleriverconsulting.com/mailman/private/info-ingres/attachments/20070426/1ba08b52/attachment.html 


More information about the Info-Ingres mailing list