UNIDAC for oracle Sometimes update not by key fields
Posted: Mon 06 Sep 2010 10:08
for example:
crate table test
(
keyField varhcar2(10) not null,
UniIdxFiled varhcar2(10) ,
memo varchar2(10)
)
keyField is key filed ;
UniIdxFiled is UNIQUE INDEX field,but can null;
memo is a normal filed;
when i execute:
uniQuery1.sql.text:='select * from test';
UniQuery1.open;
Dbgrid1.datasoure.dataset:=UniQuery1;
then:
I update data by DbGrid1;
i Monitor the SQL:
it sometimes is :
Update memo =:memo where UniIdxFiled =:OLD_UniIdxFiled ;
I Think ,it must be:
Update memo =:memo where keyField =:OLD_keyField ;
becuause ,when UniIdxFiled is null;
Update memo =:memo where UniIdxFiled =:OLD_UniIdxFiled ;
will update more data that I won't update ;
So ,I hope the automatic SQL for update or delete 's condition Must be
Key fields;
if the tables has no Key fields , when can not use UniIdxFiled too.
because UniIdxFiled can be null sometimes;
you must use condition by KeyField,or UNIQUE INDEX field with can not null,or all fields that selects;
of cause:
i often write :select a.*,rowid from test ;
this update data is OK.
crate table test
(
keyField varhcar2(10) not null,
UniIdxFiled varhcar2(10) ,
memo varchar2(10)
)
keyField is key filed ;
UniIdxFiled is UNIQUE INDEX field,but can null;
memo is a normal filed;
when i execute:
uniQuery1.sql.text:='select * from test';
UniQuery1.open;
Dbgrid1.datasoure.dataset:=UniQuery1;
then:
I update data by DbGrid1;
i Monitor the SQL:
it sometimes is :
Update memo =:memo where UniIdxFiled =:OLD_UniIdxFiled ;
I Think ,it must be:
Update memo =:memo where keyField =:OLD_keyField ;
becuause ,when UniIdxFiled is null;
Update memo =:memo where UniIdxFiled =:OLD_UniIdxFiled ;
will update more data that I won't update ;
So ,I hope the automatic SQL for update or delete 's condition Must be
Key fields;
if the tables has no Key fields , when can not use UniIdxFiled too.
because UniIdxFiled can be null sometimes;
you must use condition by KeyField,or UNIQUE INDEX field with can not null,or all fields that selects;
of cause:
i often write :select a.*,rowid from test ;
this update data is OK.