Link to home
Start Free TrialLog in
Avatar of ekehat
ekehat

asked on

Stored procedure "Multiple rows in singleton select" error

I wrote this procedure to look for users within an certein age range,
however, when I run it I get the error message: "Multiple rows in singleto
select".
Why is my select considered a singleton, and what can I do to get multiple
rows back?

(I'm running Firbird 1.0)

SET TERM !! ;
CREATE PROCEDURE SEARCH_USERS
 (MIN_AGE SMALLINT, MAX_AGE SMALLINT)
RETURNS (ID INTEGER)
AS
BEGIN
  SELECT USER_ID
     FROM USERS
     WHERE CAST (EXTRACT (YEAR FROM CAST ('NOW' AS DATE)) AS SMALLINT) -
     CAST (EXTRACT (YEAR FROM DATE_OF_BIRTH) AS SMALLINT)
  BETWEEN :MIN_AGE AND :MAX_AGE
     INTO :ID;
END!!
SET TERM ; !!


Thanks,
Elad
ASKER CERTIFIED SOLUTION
Avatar of ekehat
ekehat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chu_ko_nu
chu_ko_nu

Interbase does not support multiple rowsets from a stored procedure.  A singleton select means you can only select a single row from a stored procedure.  This is just an interbase "feature".  Your operation generates multiple rows and since interbase only allows one row (singleton) from a stored procedure, your operation is illegal.

Unfortunately, the way around this is using either views or placing the data access code in the client application.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi ehehat,

if you got the needed answer, please accept it by clicking on Accept in the header of the good answer. By this way you can express thanks for expert's support

with best regards

Janos
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to split points as follows:
                 50 points to refund for ekehat
                 50 points for lucika                        for statement SUSPEND
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

kacor
EE Cleanup Volunteer