Conditional exit for SQL 
Author Message
 Conditional exit for SQL

Hi family,

I am writing a shell script to validate .unl files for dumbness like
internal duplication of primary key columns, as well as checking them
against P-Key values already in the target table.  In order to keep
everything in a single file, I am using awk with the entire script
between the 'single quotes' and running with a "hereis"document. i.e.
dbaccess database - <<%%
... SQL code ...

I have noticed that when I run a shell script this way, dbaccess
continues on the the %% marker even if there is an SQL error. I would
like it to stop on an error and exit dbaccess.

An even greater need: If I find replicate P-Keys using the "select
count(*).., which is not an error, I would like the script to stop as

Effectively, what I want is for dbaccess to exit or abort based on a
non-zero count of some queries.

Does anyone know of a method (a kluge will do) to cause this?  I just
tried an experiment - select (1/(col - col)) from a_table to trick it
into a zero-divide.  No luck: it came up with (expression) and no rows

I am experimenting with splitting up the SQL script into several
"hereis" documents and using shell to [test for zero length] but I would
rather do it neatly in SQL directly.

Thanks for ideas.
    -- Jake (In pursuit of undomesticated semi-aquatic avians)
|Insofar as manifestations of functional deficiencies are agreed|
|by any and all concerned parties to be imperceivable, and are  |
|so stipulated, it is incumbent upon said heretofore mentioned  |
|parties to exercise the deferment of otherwise pertinent       |
|maintenance procedures.                                        |
+--------------------------------------- ( -+

Wed, 18 Jun 1902 08:00:00 GMT
 [ 1 post ] 

 Relevant Pages 

1. Conditional ORDER BY with conditional ASC or DESC

2. Conditional AND, Conditional OR


4. Exiting Windows after you Exit Paradox

5. Trigger with conditional SQL (SQL 7.0)

6. SQL Proceure in SQL Server 6.5 (exit after x iterations)

7. How do I do conditional sums in sql

8. Conditional T-SQL question


10. Conditional inside of SQL

11. how to view resulting SQl statement from conditional statemens (CASE)

12. T-SQL Conditional If... Then

Powered by phpBB® Forum Software