Hello,
I would like to know if there is a strategy for checking (preventing) duplicate records (or specific fields within records) before the current record will be posted?
The purpose of this is to be able to notify the user for incorrect values and keep the option for the user to cancel the edit.
Important to say is that i'm using cachedupdates mode!
Regards,
Frans
Check for duplicates before post
Re: Check for duplicates before post
Hello,
There is no built-in mechanism that allows checking of duplicate records in the CachedUpdates mode. You can use the BeforePost event to check it yourself and abort the posting in case of existence of duplicate records. Please note that the only way to cancel posting in the BeforePost event is to call the Abort method. This functionality is inherited from the TDataSet standard class. For more information, please read the BeforePost event description in the Delphi help.
There is no built-in mechanism that allows checking of duplicate records in the CachedUpdates mode. You can use the BeforePost event to check it yourself and abort the posting in case of existence of duplicate records. Please note that the only way to cancel posting in the BeforePost event is to call the Abort method. This functionality is inherited from the TDataSet standard class. For more information, please read the BeforePost event description in the Delphi help.
Re: Check for duplicates before post
Hello Andrey,
the problem in this case is that calls like Locate and FindKey can lead to a jump to another record.
Maybe it's better to rephrase the question: is there a method availlable to search or check for values within a dataset without changing/disturbing (the state of) the current record?
the problem in this case is that calls like Locate and FindKey can lead to a jump to another record.
Maybe it's better to rephrase the question: is there a method availlable to search or check for values within a dataset without changing/disturbing (the state of) the current record?
Re: Check for duplicates before post
To avoid changing of the current record, you should use bookmarks. Here is a code example:
Code: Select all
var
bm: TBookmark;
begin
bm := MSQuery.Bookmark; // save the current position
MSQuery.Locate(KeyFields, KeyValues, Options);
MSQuery.GotoBookmark(bm); // return to the saved position
end;
-
- Posts: 4
- Joined: Thu 01 Nov 2018 15:14
Re: Check for duplicates before post
I have the same issue. Locate is not accepted because I should check duplicates before posting. Is this a way to scan underlying in-memory storage without changing the current record and its state?
Re: Check for duplicates before post
Unfortunately, we couldn't reproduce the issue. To investigate this behavior of SDAC, please compose a small sample demonstrating the issue and send it to us, including database objects creating scripts.
You can send the sample using the contact form at our site: devart.com/company/contactform.html
You can send the sample using the contact form at our site: devart.com/company/contactform.html