Home » Developer & Programmer » Forms » Re-query updated columns
Re-query updated columns [message #87563] Sun, 16 January 2005 16:37 Go to next message
skc
Messages: 14
Registered: September 2004
Junior Member
Let say I have a db table A with columns a1,a2,a3,a4,a5 where a1 is PK. Then I retrieve record 1 (rec 1) from this table in Form. Before I press save button on the Form, another guy updated column 2 in the table and commit. Suppose I cannot change the PK on table A in the Form. What I want is a pre-save check: if one of the column is updated by anothers, just clear the block and re-populate the data to see the changes. It comes easy with this scenario using SQL like:

SELECT DECODE(A.a2, :A.a2, '0', '1') CHG_a2,
DECODE(A.a3, :A.a3, '0', '1') CHG_a3,
DECODE(A.a4, :A.a4, '0', '1') CHG_a4,
DECODE(A.a5, :A.a5, '0', '1') CHG_a5
INTO V_CHG_a2, V_CHG_a3, V_CHG_a4, V_CHG_a5
FROM A
WHERE a1 = :A.a1;

But if the table has 30 columns, it requires about 30 DECODE on the table. Is there any other ways to do that? Thank you!!
Re: Re-query updated columns [message #87585 is a reply to message #87563] Mon, 17 January 2005 23:13 Go to previous message
Himanshu
Messages: 457
Registered: December 2001
Senior Member
Hi,
The better way to handle this will be to handle the error "Record has been updated by another user" in you on-error trigger.
Add the error condition in your on-error trigger for above mentioned trigger and code that whenver this error then
execute_query;

HTH
Regards
Himanshu
Previous Topic: call an exe file from a DB Procedure
Next Topic: Only take new data(Urgent)
Goto Forum:
  


Current Time: Thu Sep 19 15:17:41 CDT 2024