I have a Table as below:
TABLE_1
{
Name varchar2(30)
Value_a number
Update_time timestamp
}
I want to conditionally update the value of update_time during the INSERT + MERGE depending on the value of "value_a". if value_a is less than 0.1, then check if update_time is null. if yes then update else don't. if value_a is greater than 0.1, then check if update_time is not null. if yes then make null.
I have a table_1_stage which I clear, then I insert all the data and then "merge or insert" in table_1 depending on the key match. I am using oracle 11g.
My Prepared Statement looks like the following: " MERGE INTO "
+ TABLE_1
+ " TABLE1 "
+ " USING TABLE_1_STAGE TABLE1S "
+ " ON (TABLE1.NAME = TABLE1S.NAME ) "
+ " WHEN MATCHED THEN "
+ " UPDATE set VALUE_A = TABLE1S.VALUE_A "
+ " WHEN NOT MATCHED THEN "
+ " INSERT ( NAME, VALUE_A) "
+ " VALUES (?, ?) "
The update_time column is new and i need to set/reset it depending on the value_a.
i know a stored procedure might be a better call but i was looking if something can be done in the insert query to perform this?