Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: NOE171/UPS Record has been deleted by another user - parameters ???
NOE171/UPS Record has been deleted by another user - parameters ???
Posted: 2002/08/15 09:01
 
I need to update 1 row in Oracle table (condition of update depend on
parameter).
Next code:
//part 1
Mainform.OCIQuery2.Close;
Mainform.OCIQuery2.Prepare;
MainFORM.OCIQuery2.SQL.Text:='select col1 from tab1 WHERE tab2=aram';
Mainform.OCIQuery2.ParamByName('param').AsInteger:=x;
Mainform.OCIQuery2.Open;
//part 2
Mainform.ociquery2.refresh;
Mainform.datasource2.dataset.edit;
Mainform.datasource2.dataset.fieldbyName('col2').AsInteger:=y;
Mainform.datasource2.dataset.post;
// x, y - defined variables
genetate error:
NOE171/UPS Record has been deleted by another user

But only 1 user works in database and he didn't delete any records.

If I don't use parameter (SQL property is select col1 from tab1 WHERE
tab2=:123 and not use part 1 of code) code is correct.

CacheUpdates property is False
RE: NOE171/UPS Record has been deleted by another user - parameters ???
Posted: 2002/08/15 10:12
 
Did you mean Col2 instead of Tab2 in your select statement?
You need to select ROWID or primary key columns to be able to update dataset.
MainFORM.OCIQuery2.SQL.Text:='select col1, rowid from tab1 WHERE col2=aram';
or
MainFORM.OCIQuery2.SQL.Text:='select col1, id_col from tab1 WHERE col2=aram';
MainFORM.OCIQuery2.FieldByName('id_col').ProviderFlags := [pfInKey];
If col1 is primary key and you want to update it, simply call
MainFORM.OCIQuery2.FieldByName('col1').ProviderFlags := [pfInKey];
In your code call to Refresh after Open is redundant
By the way you can repalce all your code with single line:
Database.ExecSql('update tab1 set col1='+IntTOStr(y)+' where col1='+IntoToStr(x));
Or use this more 'elegant' code:
Query2.SQL.Text := 'update tab1 set col1=:y where col1='
Query2.ParamByName('x').AsInteger := x;
Query2.ParamByName('y').AsInteger := y;
Query2.ExecSQL;