Board index » off-topic » Best way to update internal modified date in record update

Best way to update internal modified date in record update


2007-09-03 02:23:23 AM
off-topic14
I have internal "modified date" field (for briefcase model) in my
interbase server which is hidden from the clients. When client posts a
modified record to datasnap server I would like to also update hidden
"modified date" field with current date stamp. Since each IBQuery has
their own IBTransaction I can't execute a sql in Before/AfterUpdateRecord
event and since "modified date" is not included in delta I cannot set the
value in BeforeUpdateRecord. What would be the best way to set the
datestamp.
One way might be to store update sql in AfterUpdateRecord event into
tstringlist and execute it in AfterApplyUpdates (search from tstringlist
via providername), but I'm not sure if the transaction is closed then
already. Sounds complicated anyway.
Any ideas?
 
 

Re:Best way to update internal modified date in record update

Janne Timmerbacka wrote:
Quote
I have internal "modified date" field (for briefcase model) in my
interbase server which is hidden from the clients. When client posts a
modified record to datasnap server I would like to also update hidden
"modified date" field with current date stamp. Since each IBQuery has
their own IBTransaction I can't execute a sql in
Before/AfterUpdateRecord event and since "modified date" is not included
in delta I cannot set the value in BeforeUpdateRecord. What would be the
best way to set the datestamp.

One way might be to store update sql in AfterUpdateRecord event into
tstringlist and execute it in AfterApplyUpdates (search from tstringlist
via providername), but I'm not sure if the transaction is closed then
already. Sounds complicated anyway.

Any ideas?
Using before update/insert trigger on table?
CREATE TRIGGER MYTABLE_BI0 FOR MYTABLE
ACTIVE BEFORE INSERT POSITION 0
as
begin
modified_date = current_timestamp;
end
Danny
 

Re:Best way to update internal modified date in record update

Thank you. How didn't I think of that?
Million thanks
Janne
ps. Here is how I did it:
CREATE TRIGGER "RYHPA615MODIFIEDINSERT" FOR "RYHPA615"
ACTIVE BEFORE INSERT POSITION 0
as
begin
new."ZXC_MODIFIED" = current_timestamp;
end
CREATE TRIGGER "RYHPA615MODIFIEDUPDATE" FOR "RYHPA615"
ACTIVE BEFORE UPDATE POSITION 0
as
begin
new."ZXC_MODIFIED" = current_timestamp;
end
 

{smallsort}