Subject Re: [firebird-support] Strange SELECT FIRST 1
Author Ann Harrison
On Wed, Sep 12, 2012 at 6:18 AM, Mr. John <mr_johnmr@...> wrote:

> Hi,I'm using FB 2.5.1.26351 SS on XP SP3,I have one stored
> procedure,also inside
> FOR EXECUTE STATEMENT loop I have this query
>
> SELECT FIRST 1 id_cf,numar FROM CB_FC WHERE ID_CF=:wid_cf
> AND numar=:wNUMAR INTO :xid_cf,:xnumar;
>

That is an odd statement. If you know that ID_CF and numar combined form a
unique key, you don't need the "FIRST 1". If those fields don't form a
unique key, then your getting one of the rows that match those values at
random. Either drop the "FIRST 1" or add an "ORDER BY" to
get deterministic results.

Good luck,

Ann


[Non-text portions of this message have been removed]