Re: Stored Procedure: Check For No Rows Found
Posted in 1996
Jonathan Leffler wrote:
>
> Oops... Sorry about the truncated posting!
>
> DEFINE magic INTEGER;
>
> LET magic = 0;
> FOREACH SELECT name INTO v_name FORM table_x WHERE x_key = p_key
> LET magic = 1;
> END FOREACH
>
> IF magic = 0 THEN
> -- You know you didn't find anything
> END IF
>
> There may be a better way of doing it; this does work.
>
> Yours,
> Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>
> >From: pcarter@hpcc01.corp.hp.com (Preston Carter)
> >Date: Fri, 28 Jun 1996 02:41:12 GMT
> >X-Informix-List-Id: <news.25524>
> >
> >OK, I give up. In a stored procedure how do you find out if there are
> >no rows found?
> >
> >Suppose I have the following code:
> >
> > SELECT name
> > INTO v_name
> > FROM table_x
> > WHERE x_key = p_key;> >
> >What do I write after that to check if there is no matching row?
> >Thanks.
How about SELECT COUNT(*) etc? How woul that compare in terms of speed?
It would provide the additional detail of how many rows?
Ian Goddard