views:

35

answers:

2

I want to return custom values as the values of the rows in case when no rows are fetched by executing the stored procedure

How do i do that?

A: 

Just do your own Select statement containing the values you want to return to the user. Something like this:

Select
   MyValue1,
   MyValue2,
   Myvalue3
Randy Minder
+2  A: 

You can use the built-in function ROW_COUNT() to test if any rows have been returned from a query. If the number of rows returned is zero, then you can run an alternative SQL statement to return your custom values:

--Execute your SQL statement
SELECT * FROM myTable

IF ROW_COUNT() = 0 
BEGIN
     --SQL to return your custom values instead
     SELECT value1, value2, etc.
END
Jazza
this is not working with mysql
abs
@abs: sorry, didn't realise you were using MySQL - try ROW_COUNT() instead.
Jazza