472,143 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Printing No Records Found

I am new to this. Someone please help.

I am creating stored procedures that queries the tables to pull certain information together in a listing (report). I would like to be able to print to the user "No records found", if no records were found based on the search criteria. I can able to query the information, but can't get the "No records found" to print. The listing just comes back with no records.

Is there a canned syntax/statement to make this happen and should it be placed before or after the select statement?

Is there some sort of end of file checking that needs to happen?
Aug 7 '06 #1
2 3846
try an IF ELSE query


IF (there are records) { DO SOMETHING
} ELSE {

you can expand on this by using ELSEIF instead of the first ELSE statement as long as you finish the whole thing with an ELSE statement

hope this helps
Aug 7 '06 #2
Thank you. I have been using the if, else statement. It seems to work in some of my stored procedures, but not the others. Here is a sample of what I have done. Any more suggestions?

If Exists (select 1 from table_name, table_name1
where table_name.field name = table name1.field_name)

Select .......

print ' no records found'
Aug 9 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by James | last post: by
1 post views Thread by Earl Anderson | last post: by
1 post views Thread by John | last post: by
1 post views Thread by benfly08 | last post: by
4 posts views Thread by paquer | last post: by
1 post views Thread by paquer | last post: by
18 posts views Thread by Brett | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.