redirecting sql query output to a file

Hi,

I am executing sql files in my unix shell script. Now i want to find whether its a success or a failure record and redirect the success or failure to the respective files. meaning.

success records to success.log file
failure record to failure.log file.

As of now i am doing like this.
db3 connect to a
db3 connect to b
db2 -tvf "${var[Perforce_Script_Name]}" > $output
grep -v "successfully" "${var[Perforce_Script_Name]}" >suc_Logfile
grep -v "SQLSTATE" "${var[Perforce_Script_Name]}" >fail_Logfile
But i am not able to see any thing in those files. pls help me.

Thanks for your help and time.

Those greps will find every line that does not contain "successfully" in your script and store them in suc_Logfile, and every line that does not contain "SQLSTATE" in the script, in fail_Logfile.

That doesn't sound like what you want.

If I can assume $output is what you want to look over, try this for the grep portion:

grep "successfully" $output > suc_Logfile
grep "SQLSTATE" $output > fail_Logfile