Subject | Re: [firebird-support] Multiple Rows Error in Stored Procedure |
---|---|
Author | Helen Borrie |
Post date | 2004-12-20T23:34:28Z |
At 11:19 PM 20/12/2004 +0000, you wrote:
doesn't have a UNIQUE constraint, the engine doesn't know that. Solve the
problem by putting the SELECT statement into a FOR loop (if you can do so
without breaking the logic of your SP); or, if you are only fetching the
one column, guarantee a singleton by using SELECT DISTINCT or a GROUP BY
clause.
As to the apparent anomaly, well, if the table is empty then any indexes
would be empty, hence, one would suppose, no reason for the uniqueness
validation to be visited at all.
./hb
>I am getting the error "Multiple rows in singleton select" when i runYou know that the column Value is unique but, if it's not the PK and it
>my stored procedure.
>
>The stored procedure has a select statement
>Select Field from Table where Value= InputValue into OutputValue.
>
>Now i know what the error means. If the field has more than one
>record where it is equal to the input value, it will give you that
>error.
>
>However, looking at the data, i know for sure there is only 1 record
>for each value of this field.
>
>In fact, I copied the table, and had the SP select from the copied
>one. If the copied table had no records, no error. If it had just one
>record, i get the error.
>
>What might be the cause of the error?
doesn't have a UNIQUE constraint, the engine doesn't know that. Solve the
problem by putting the SELECT statement into a FOR loop (if you can do so
without breaking the logic of your SP); or, if you are only fetching the
one column, guarantee a singleton by using SELECT DISTINCT or a GROUP BY
clause.
As to the apparent anomaly, well, if the table is empty then any indexes
would be empty, hence, one would suppose, no reason for the uniqueness
validation to be visited at all.
./hb