Subject Re: [IBO] delete from query
Author Helen Borrie (TeamIBO)
At 09:40 PM 02-06-02 +0000, you wrote:
>First I tryed to delete using a IB_Query without any special
>DeleteSQL string. I get an error msg that I could not delete the
>used or active record. I could not undestand the logic, since I was
>using a query to find if value1 was present in table2, if it was
>present, I would like to delete the record in table1.
>The table1 structure is:
>key
>.....
>field1
>field2
>in which we can have several diferent records with the same values in
>fields 1 and 2.
>So I set the deleteSQL string to: 'delete from table1 where field1
>= 'Y' and field2 = :field2'
>using the instructions: 'Myquery.delete' I get an error that I was
>trying to delete multiple records. Ok, I realy want to delete
>multiple records.

The dataset methods are positioned, meaning that they act upon the row
which is currently pointed to by the cursor. That's why we have Keylinks
and why the update and delete methods can only operate on a single row.

If you want to use your dataset as a "row selector" for multiple updates or
deletes, pass the parameters to a separate ib_dsql statement (which can be
an Execute-style stored procedure) and don't call Delete (or Edit, as the
case may be).

In short, if your dataset update or delete call cannot uniquely point to a
single row, you will get a multi-row error. Use the dataset methods for
row-by-row operations and DSQL or SPs for anything else.


regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com