Skip to Content
author's profile photo Former Member
Former Member

Re: Inconsistent behaviour of Sybase SQL anywhere update column trigger

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 24, 2014 at 06:43 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.