Subject Re: [firebird-support] UPDATE ... RETURNING question
Author Mauricio Junqueira
Hello.

Maybe you show use a FOR loop to create a order in what the records are updated so you could take the last two rows using select FIRST 2 .. and order by DT_END DESC.



MaurĂ­cio Junqueira
Eng. Eletricista
Rn. 1014725631D-GO
claro: +5562-8600-8895

On Mon, Mar 12, 2018 at 4:55 AM, cornievs@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
 

Hi


I understand UPDATE ... RETURNING only works with single select. 


I have the following procedure


UPDATE STAFF_EVENTS SET DT_END = current_timestamp(0),

       LEN = dateadd(minute, datediff(minute, dt,  current_timestamp(0)), cast('30.12.1899 00:00' as Timestamp))

        WHERE STAFFCODE = :staffcode and EVENTYPE = 1001 and DT_END is NULL RETURNING LEN, DT_END into DURATION, END_DT; // DURATION and END_DT is variables


which may effect more than one row.  I only want the last row effected values for the RETURNING values.


How must I rewrite this.


Thanks for any help


Cornie