on 07-24-2014 7:24 PM
I have an Oracle trigger which updates only specific columns.
I want the column 'change_date' only to be updated if 'amount' or 'quantity' changes; all other column changes should not update the 'change_date' column.
here is the trigger:
create trigger bu_s1_sales_analysis
before update on s1_sales-analysis
for each row
begin
if not updating('change_date') and updating('amount') or updating('quantity)) then
:new.change_date := sysdate;
end if; end;
/
My SQLanywhere attempt looks like this:
create trigger bu_s1_sales_analysis
before update on s1_sales_analysis
referencing new as new_upd
for each row
begin
if not update('change_date') and update('amount') or update('quantity')) then
set new_upd.change_date - current timestamp;
end if;
end;
I get a "syntax error near 'change_date' on line 7 message.
Thanks
Murray,
Single quotes indicate string values (the value 'change_date'), while double quotes indicate identifiers (the column named "change_date").
Changing the single quotes to double quotes around the column names should fix your problem.
Also, your set statement is incorrect. It is missing an = operator.
hth,
--Jason
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.