Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Richard Thomas — — source: Informix-list mailing list archive (1991-1998)
PRAVEEN MOHANAN wrote:
>
> Hi...Users....
> Env. Informix OWS 7.20. What exception is raised where
> there r no rows found after a select stmt. I am trying to write a
> procedure & wanted to trap this exception. Is there any way to find ,
> except
> select count(*) from ..... where....>
> if the count < 1 then
> .....
> end if
>
>
> regards,
>
> Praveen
>
Praveen:
I'm not sure how you intend to use this (is the SQL statement whose result=
you wish to test inside or outside the procedure?) Presuming it's =
outside, try this:
CREATE PROCEDURE stop_if_no_rows()
IF DBINFO('sqlca.sqlerrd2') =3D 0 THEN
RAISE EXCEPTION -746, 0 , "No rows were found in that query"; END IF;
END PROCEDURE;
SELECT *
FROM customer
WHERE 1 =3D 0
INTO TEMP a_temp_table WITH NO LOG;EXECUTE PROCEDURE stop_if_no_rows();SELECT ...
HTH
RET
+------------------------------------------+
| Richard Thomas |
| DBA - Marketing Information Systems |
| Optus IT |
| email: richard_thomas@yes.optus.com.au |
| Ph: +61 2 9342 7188 |
| "My opinions are my opinions" |
+------------------------------------------+
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.