Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
grep SQL code
Name: bhben Date: November 30, 2004 at 05:31:07 Pacific OS: Windows XP CPU/Ram: P4, 512MB
Comment:
Hi, i have a script that runs some SQL code and prints the count of records in a table to another file. This file is being used to setup XML code, so first i will echo a tag, then have the tables and then the closing tag. What i wish for is to setup an IF statement around this so that is there is a 0 count of records trhe word PASS will be written to XML and if there are records then FAIL will be written to XML. Sort of like this: <result>PASS</result> <data> records tablename 0 table </data>
Or a fail if there are records. I currently only have the data tag. So far i am echoing the tags and sending the ouput to $dir1, i then open sql, run an sql script and send this to $dir1 and then exit sql and echo the next tag. I am trying to egrep but am struggling since i can't use egrep whilst in sql. Please help.
Name: Jim Boothe Date: November 30, 2004 at 07:54:48 Pacific
Reply:
I would pull all of my table row counts first (suppress headers and spool to a file), then process that file to build your XML code, and your logic at that point could see if a row count is zero or not:
spool counts.lst select 'emp', count(*) from emp; select 'dept', count(*) from dept; select 'ord', count(*) from ord; spool off
Summary: An example of a package is here. I haven't revised it in a while and it could do with an update now I look at it, but maybe it will give you some ideas. If for any reason you are after a rambling rant...
Summary: Hi i have written a shell script which runs some sql queries in oracle. the code looks like this sqlplus username@NJCMTOMS/password < $HOME/devel/oms/arg/cleanupsql.sh cleanupsql.sh has the sqls to...
Summary: Jim, thanks alot for your help. I've gone ahead and incorporated your code into what I've got, and made a little headway with the whole "detect a new file" part. Please take a look if you can and let ...