Re: SQL Error Checking in Shell Scripts + philosophy!
Posted in 1996
> Is there a graceful way to abort a shell script when an SQL error occurs? > Currently, we are using shell scripts to run SQL to load flat files > into tables using the following syntax: > isql <database> load from "filename" insert into "tablename" > [...] This isn't exactly the answer you want to hear, but IMNSHO: You'd be a lot better off avoiding loading like this, ESPECIALLY if there is the possibility of an error. I use loading and unloading as a means of emptying and rebuilding a table, and of importing/exporting data that is of *exactly* the same nature. Where there is significant possibility of bad data you should pass it thru a filter, such as a 4GL program. This way you have control over each row, and each column within each row. Having just built a data warehouse, I'm very sensitive to the quality of the data contained in corporate databases. Basically, it stinks. It's been my experience that one should take every opportunity to check, validate, verify, and purify data. Sometimes there are good reasons not to (huge legacy systems predicated on a "load it and love it" philosophy), but there's always a nagging suspicion about the quality of the data. If anyone is performing any statistical analysis (that is, using the data without seeing the individual rows) then the problem is even worse, because errors are not readily apparent. Writing such a filter is often hard, as the programmer often has very little idea what the data should look like. That's when the data administrator (distinct from the DBA) refers him to the meta-data tables. (You *do* have meta-data, right?) These tables contain descriptions of the nature of the data contained in the other tables. Typically things like: verbose description of the nature of the data in the column range of values expected in this column source of data transformations through which the data has gone a point-of-contact who knows about this data business reasons for keeping this data and so on. That's an earful from such a simple question, but you've pushed one of my buttons. 'Hope it helps, Clem __________________________________________________________________ | Clem Akins Standard Disclaimers Apply | |Reynolds Metals Co, Alloys Plant "Climb High, Cave Deep!" | | Muscle Shoals, Alabama USA cwakins@leia.alloys.rmc.com | |________________________________________________________________|