Print Thread
"record has been changed by another user" on delete
#43487 03/02/12 11:48 AM
Joined: Mar 2012
Posts: 1
A
ACC Offline OP
Member
OP Offline
Member
A
Joined: Mar 2012
Posts: 1
Hi,
Since I have installed newest version 4.1.2.2 I have error "record has been changed by another user" when I try delete record from database. If I use "Edit" function before "Delete" everything is OK.
Before I have had version 4.0.6.2. I use Delphi 7.
Could you help me in this case?

Re: "record has been changed by another user" on delete
ACC #43495 03/05/12 10:45 AM
Joined: Aug 1999
Posts: 22,216
Member
Offline
Member
Joined: Aug 1999
Posts: 22,216
Which Delphi version are you using?


Marco Kalter
Allround Automations
Re: "record has been changed by another user" on delete
Marco Kalter #44108 06/19/12 12:26 PM
Joined: Jun 2012
Posts: 3
R
Member
Offline
Member
R
Joined: Jun 2012
Posts: 3
Hello Marco,

We are currently using DOA 4.1.2.2 with Delphi XE, and we get this error too.

This is what we found out so far:

We have a dataset with a query like:
select tab1.rowid, tab1.*, tab2.field1, tab2.field2, tab2.*
from table1 tab1, table2 tab2
where tab1.id(+) = tab2.tab1_id

tab1 and tab2 both have a field with the name ID when you open the dataset this will result in two different fields 1 called ID and 1 called ID_1. When we delete a record form the dataset we get the error "record has been changed by another user".

After some research and debugging OracleData we came across the code that checks if the data is changed here you check the value of the fields. What we saw is that when ID_1 was being checked the original fieldname ID is used and we get back that the record is changed.

In the function TOracleFieldInfo.QueryValueIndex you fetch the the field index, but here you use the ColumnName and not the FullName. We changed this in that function and that seems to work for us.

Can you check if this is correct, if not can you supply us with a correct solution. We are currently working towards a release of our software so we are in a bit of a hurry with a solution.

Regards,

Richard Floor

Last edited by RFloor; 06/20/12 06:19 AM.

Richard Floor
Erasmus MC
Re: "record has been changed by another user" on delete
RFloor #44111 06/20/12 09:52 AM
Joined: Aug 1999
Posts: 22,216
Member
Offline
Member
Joined: Aug 1999
Posts: 22,216
I don't think this check currently works when the query has ambiguous field names. You would need to provide an alias to make them unique or disable the check.


Marco Kalter
Allround Automations
Re: "record has been changed by another user" on delete
Marco Kalter #44131 06/25/12 06:08 AM
Joined: Jun 2012
Posts: 3
R
Member
Offline
Member
R
Joined: Jun 2012
Posts: 3
Hello Marco,

Providing aliases in not an option. The query is used in a generic component and we need all the fields from the second table and the fields in the second table can be different all the time.

This is what we did to resolve the issue:

function TOracleFieldInfo.QueryValueIndex(Q: TOracleQuery): Integer;
var Attr: TObjectAttribute;
begin
//Old Result := Q.FieldIndex(ColumnName);
Result := Q.FieldIndex(FullName); // New
if Result >= 0 then
begin
if (InfoType = itField) and (Q.FieldType(Result) <> DataType) then Result := -1;
if (InfoType = itAttr) then
begin
if (Q.FieldType(Result) <> otObject) then
Result := -1
else begin
Attr := Q.ObjField(Result).AttrByName(AttrName);
if (Attr = nil) or (Attr.DataType <> DataType) then Result := -1;
end;
end;
end;
end;

You said we could disable the check. What do you mean by that?

Regards,

Richard Floor


Richard Floor
Erasmus MC
Re: "record has been changed by another user" on delete
RFloor #44134 06/25/12 09:56 AM
Joined: Aug 1999
Posts: 22,216
Member
Offline
Member
Joined: Aug 1999
Posts: 22,216
You can set the LockingMode property to lmNone.


Marco Kalter
Allround Automations
Re: "record has been changed by another user" on delete
Marco Kalter #44141 06/26/12 11:17 AM
Joined: Jun 2012
Posts: 3
R
Member
Offline
Member
R
Joined: Jun 2012
Posts: 3
We have tried that option but the error still occured.


Richard Floor
Erasmus MC
Re: "record has been changed by another user" on delete
RFloor #44148 06/27/12 09:49 AM
Joined: Aug 1999
Posts: 22,216
Member
Offline
Member
Joined: Aug 1999
Posts: 22,216
If LockingMode = lmNone no locks or checks are performed during the delete operation. Are you sure this is from the same dataset?


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.028s Queries: 14 (0.008s) Memory: 2.5300 MB (Peak: 3.0418 MB) Data Comp: Off Server Time: 2024-05-11 15:43:54 UTC
Valid HTML 5 and Valid CSS