Subject | Re: [firebird-support] Re: Multiple Rows Error in Stored Procedure |
---|---|
Author | Nando Dessena |
Post date | 2004-12-22T12:10:47Z |
Adam,
A> It is not about whether or not the query returns multiple records, but
A> whether or not there is the potential to have multiple records.
Wrong. It's precisely the row count of the returned result set that
triggers the error.
A> Keep
A> in mind that the Stored Procedure needs to operate even after you fill
A> the table with whatever data it accepts. If it is technically possible
A> to put data into the table that will cause this query to return
A> multiple records, then that error is appropriate.
That would be a little too restrictive, wouldn't it?
A> Try this sort of statement. This guarantees a singleton result
A> regardless of the where clause (even if it is empty).
A> Select First 1 Field
A> From Table
A> where Value = InputValue
A> into :Output Value
This is a way to work around the problem in some cases (sometimes an
error is more appropriate than blindly selecting the first of multiple
tuples), but finding and fixing the real cause would be better IMHO.
Ciao
--
Nando Dessena
http://www.flamerobin.org
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================
A> It is not about whether or not the query returns multiple records, but
A> whether or not there is the potential to have multiple records.
Wrong. It's precisely the row count of the returned result set that
triggers the error.
A> Keep
A> in mind that the Stored Procedure needs to operate even after you fill
A> the table with whatever data it accepts. If it is technically possible
A> to put data into the table that will cause this query to return
A> multiple records, then that error is appropriate.
That would be a little too restrictive, wouldn't it?
A> Try this sort of statement. This guarantees a singleton result
A> regardless of the where clause (even if it is empty).
A> Select First 1 Field
A> From Table
A> where Value = InputValue
A> into :Output Value
This is a way to work around the problem in some cases (sometimes an
error is more appropriate than blindly selecting the first of multiple
tuples), but finding and fixing the real cause would be better IMHO.
Ciao
--
Nando Dessena
http://www.flamerobin.org
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================