Subject Re: [IBO] delete from query
Author emgfyah2002
Dear Helen
Thank you for your answer, and it's clear why I could not delete
several records. But I did not understand why I get the error in the
first case: delete a single record. I read the table1 and after test
the existence of the value in the second table, to delete the record
in table1 rises an error. How could I do that ?
thank you
Edison
PS.: I followed your sugestion (in another question) and I had buyed
a copy of "Gettingstarted", but I could not find one line in it about
how to deal with edits and deletes. Here my suggestion to add some
instructions about, because it is a very different from conventional
delphi usage. By the way, the information about Keylinks usage, in
my opinion, its also very poor and it becomes very difficult to the
people with no experience in IBObjects ( like me ) to use it.

--- In IBObjects@y..., "Helen Borrie (TeamIBO)" <helebor@t...> wrote:
> 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