I want to return custom values as the values of the rows in case when no rows are fetched by executing the stored procedure - is there a way to do that?
A:
What you are probably looking for is the 'DECLARE CONTINUE HANDLER FOR NOT FOUND' syntax. There is a (rather cryptic example) at http://dev.mysql.com/doc/refman/5.0/en/declare-handler.html
please comment if you need clarifications.
e4c5
2010-02-11 01:49:28
A:
if 0 = (select count(*) from tbl where conditions)
select 'None' as s, 0 as n
else
select s, n from tbl where conditions
If the rows are returned from a procedure, as opposed to a select, execute into a temporary table, then the same excercise. Like this:
create table #tmp (s varchar(17), n integer)
insert into #tmp
execute myproc
Seva Alekseyev
2010-02-11 01:57:46