Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
Posted: 2000/10/30 09:50
 
Hi.

Maybe its a simple problem, but i cannot delete a rekord when my query has a where part, however my updatesql sqldelete prop is filled. Dunno why. Update is works fine but delete not .

The error msgs:
- if i use a DBNavigator delete button:
got EOCIDBError with 'NOE171/UPS - Record has been deleted by another user'
but its NOT.
- if i call directly the OCIUpdateSQL1.ExecSQL(skDelete); function
got EOCIDBError with 'NOE07/VAR Bad or Undefined variable [KOD] value type 0'

The OCIUpdateSQL.SQLupdate which works fine:

UPDATE xxxx
SET
PKOD = KOD,
EXKOD = :EXKOD,
BVSORSZ = :BVSORSZ,
BVDATUM = :BVDATUM,
....
KOTESEGYS = :KOTESEGYS
WHERE
PKOD = :OLD_PKOD and
EXKOD = :OLD_EXKOD and
BVSORSZ = :OLD_BVSORSZ

The OCIUpdateSQL.SQLdelete which sux:

DELETE FROM xxxx
WHERE
PKOD = KOD and
EXKOD = :EXKOD and
BVSORSZ = :BVSORSZ

These fields are my table's primary key.

Any idea???

One more important thing!!!
^^^^^^^^^
When i tried to delete the record after the
NOE171/UPS error, the query simple deleted the WHOLE TABLE !!!! I loved it.
RE: OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
Posted: 2000/10/30 11:58
 
Hi,

I observed the same thing, and I have no idea about the reason. One solution: in befordelete event handler delete the record yourself and then say abort

Bali
RE: OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
Posted: 2000/10/31 14:29
 
Hi!

I use the simple thing for that.
For example query = tMyQuery has update SQL component with right Insert, Delete, Update &
Refresh. ID field is a primary key.
I set such code on event AfterPost :

procedure TDM.tMyQueryAfterPost(DataSet: TDataSet);
var i : integer;
begin
i := DataSet.FieldByName('ID').AsInteger;
DataSet.Refresh;
DataSet.Locate('ID',i,[]);
end;

It's help correct record position and you
can delete a simple record.
RE: OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
Posted: 2000/11/01 13:13
 
Hi.

It is (was) a bug ;( Record deletion from TOCIQuery, that have parameters in SQL, with the same name as some of fields, raise "NOE171/UPS". To fix that, find in NCOciUpdateSQL.pas unit procedure TOCIUpdateSQL.SetParams. And replace following code:

if AnsiCompareText(parName, SDefPrefix + 'SAVE') = 0 then
Param.AsBoolean := soSave in ApplyOptions
else if not (DataSet is TOCICustomQuery) or
(TOCICustomQuery(DataSet).FindParam(parName) = nil) then begin
Old := Par2FieldName(parName) = -1;
RE: OCIQuery + OCIUpdateSQL = Cannot delete a simple rekord :-(
Posted: 2000/11/01 13:16
 
Forget to say ... It will be "officially" fixed in v 0.9.1. I will notify about it.