Subject Re: [firebird-support] MULTIPLE ROWS IN SINGLETON SELECT in SP
Author Lucas Franzen
Tanz Anthrox schrieb:

> DO
> BEGIN
> SELECT COUNT(*) FROM BOM b2 WHERE b2.PARENT=:CHILD INTO :HAS_CHILDREN;
> IF (HAS_CHILDREN<>0) THEN
> BEGIN
> select child,childname from PR_BOMVIEW(:CHILD) INTO :CHILD,:CHILDNAME; /* THIS LINE CAUSES MULTIPLE ROWS IN SINGLETON SELECT */

of course it does, if there is more than one child. (You can't do a
plain SELECT when there are several records!)

Do you want to return all children???

Then change it to:

IF ( HAS_CHILDREN <> 0 ) THEN
BEGIN
FOR select child,childname from PR_BOMVIEW(:CHILD)
INTO :CHILD,:CHILDNAME
DO BEGIN
SUSPEND;
END
END
ELSE SUSPEND; /* if you want to return the records without childrten,
too */

AND:
Never use COUNT (*) for checking record existance.
Use EXISTS instead!

Luc.