How would I check for duplicates before posting data?
I've been given this via stackoverflow but not sure how to implement it.
update or insert into KEYWORDLIST (KEYWORD) values(:KEYWORD) matching(KEYWORD)
I was guessing I would do this onNewRecord or BeforePost...
Thank you
-Brad
Using: D2K9, Zeos 7, Firebird 2.1
check for duplicate before post
Moderators: gto, EgonHugeist, olehs
In my opinion you can:
1. write a stored procedure where you call a select which verify is this record already exists. If exists you don't need to do the update/insert
2. write that select in your Delphi code
3. insert the sql code above in a try/except .. if you receive an error obviously record already existed
1. write a stored procedure where you call a select which verify is this record already exists. If exists you don't need to do the update/insert
2. write that select in your Delphi code
3. insert the sql code above in a try/except .. if you receive an error obviously record already existed
After looking at the demo.
1. I need to have a ZUpdateSQL component
2. I need to setup the params. (Not 100% sure on how these params work, but I think i've got it.)
3. Setup the SQL for the insert/update/delete/refresh using the params
The one thing the demo doesn't do is update the dataset after the edit is completed. How would I go about doing that? the best way? I'm guessing the ZQuery1AfterPost procedure and then call ZQuery1.Refresh;
Thanks
-Brad
1. I need to have a ZUpdateSQL component
2. I need to setup the params. (Not 100% sure on how these params work, but I think i've got it.)
3. Setup the SQL for the insert/update/delete/refresh using the params
The one thing the demo doesn't do is update the dataset after the edit is completed. How would I go about doing that? the best way? I'm guessing the ZQuery1AfterPost procedure and then call ZQuery1.Refresh;
Thanks
-Brad
Yes, something likebtray77 wrote:After looking at the demo.
? I'm guessing the ZQuery1AfterPost procedure and then call ZQuery1.Refresh;
Code: Select all
procedure TForm1.ZQuery1AfterPost(DataSet: TDataSet);
begin
DataSet.DisableControls;
try
DataSet.Refresh;
finally
DataSet.EnableControls;
end;
end;