Board index » delphi » IBQuery/IBUpdateSql...

IBQuery/IBUpdateSql...

Hello there...

   I need create Delete Query in run time... but the user defines the data
to save in database creating documents and fields.
  Some this documents can duplicate all fields... and when I try delete one
record... the delete query deletes One, Two or more records and raise
"Update Failed".

How can I makes a delete  sql statement in this case? Are there one
identificator to use in Interbase (RecNum?), something ROWID in Oracle?

thanks so much....

Otvio

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.265 / Virus Database: 137 - Release Date: 18/7/2001

 

Re:IBQuery/IBUpdateSql...


Quote
"Otvio" <ota...@sintel.com.br> wrote in message news:3b60273c_1@dnews...

>    I need create Delete Query in run time... but the user defines the data
> to save in database creating documents and fields.
>   Some this documents can duplicate all fields

You must find a way to allow each such record to have a *unique* identity.
This can be a single field or a few together, but it is a requirement if you
want to be able to operate on any single record later.

Quote
>... and when I try delete one
> record... the delete query deletes One, Two or more records and raise
> "Update Failed".

> How can I makes a delete  sql statement in this case? Are there one
> identificator to use in Interbase (RecNum?), something ROWID in Oracle?

There are no record numbers or ids provided by Interbase, you must provide
them yourself.

--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
"Some see private enterprise as a predatory target to be shot, others as a
cow to be milked, but few are those who see it as a sturdy horse pulling the
wagon." - Winston Churchill

Re:IBQuery/IBUpdateSql...


Quote
> You must find a way to allow each such record to have a *unique* identity.
> This can be a single field or a few together, but it is a requirement if
you
> want to be able to operate on any single record later.
> ...
> There are no record numbers or ids provided by Interbase, you must provide
> them yourself.

You can use IB generators to create unique IDs, but I find it rather anoying
to get the value back to my user. So in no C/S environnement I use this proc
to obtain a free ID.

function TFDataModule.NewID(table_name, table_key : string) : integer;
begin
 with IBSQL1 do begin
  Close;
  SQL.Clear;
  SQL.Add('SELECT MAX(' + table_key + ') FROM ' + table_name);
  ExecQuery;
  Result := Fields[0].AsInteger + 1;
  Close;
 end; {with}
end;

It doesn't allow safe insertions, i find it rather handy.

DL.

Other Threads