Subject Re: [firebird-support] Re: Can I delete a row that is the subject of a query that is deleting it??
Author Helen Borrie
At 01:49 PM 16/02/2007, you wrote:
>Can you be a bit more specific?
>--- In, Hans <hhoogstraat@...> wrote:
> >
> > Maybe the use of a CURSOR ?

For Fb 1.5.x or lower:

FOR SELECT docline_id /* assuming this is the PK */
FROM docline
INTO :v_docline_id
/* where etc */
as cursor c DO
DELETE from docline WHERE current of c;

For Fb 2.0 or higher, more bells and whistles added - see the release notes.

Advantage of using a cursor: direct operation on the current row via
the rdb$db_key which is more efficient if it's a bulk op.

Don't forget to handle exceptions from locking conflicts.


p.s. watch the requoting! threads turn into nightmares when you
persistently top-post and requote
! ^ !