85 pts.
 How do I use the results of count(*)=0
I am using SQL to code a select statement. If the result of the statement = count(*)=0, I want to put a message out on a report.

Software/Hardware used:
ASKED: October 30, 2008  11:18 AM
UPDATED: November 10, 2008  7:12 PM

Answer Wiki:
More information is needed here. How you assign the result of a query to a variable, or how you put a message on a report, depends on the programs/platform you are using. I hope this answers your question. The platform is LINX. I am writing in SQL. Each time I encounter an error I am writing to an error Log table. At the end of the processing, I selecting everything from that table where the error_date is equal to the sysdate. What I wanted was when there are NO errors for that run, instead of a blank report, Iwanted to write '** NO ERRORS FOUND **. I don't believe I am assigning a result of the query to a variable. In fact, that's 1 of the things I've been trying to do & then query the variable so that when it's 0 I can put out the message. Everything I've tried has come back with an error.. --rem creates an error report/file of those errors just identified spool c:studentrefund.errors.from.isis.csv DEFINE _EDITOR= pico SET heading off SET feedback off SET echo off SELECT ERROR_ID, ERROR_PIDM, ERROR_DATE, ERROR_REASON, ERROR_USER_ID FROM error_log WHERE ERROR_DATE LIKE TRUNC(SYSDATE); / commit; spool off -------- Thanks for clarifying this. I think you could use another query to count the errors. Something like this: <pre> -- display a message when no errors are found, or null when errors exist SELECT decode(count(*),0,'** NO ERRORS FOUND **',null) FROM error_log WHERE ERROR_DATE LIKE TRUNC(SYSDATE); -- and then the query that shows the actual errors SELECT ERROR_ID, ERROR_PIDM, ERROR_DATE, ERROR_REASON, ERROR_USER_ID FROM error_log WHERE ERROR_DATE LIKE TRUNC(SYSDATE);</pre> Hope this helps.
Last Wiki Answer Submitted:  October 31, 2008  9:32 pm  by  Sherryborden   85 pts.
All Answer Wiki Contributors:  Sherryborden   85 pts. , carlosdl   63,580 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I’d like to thank you for the help. It’s exactly what I wanted.
Sherry

 85 pts.

 

I’m glad it worked.
Best regards,

 63,580 pts.