Subject | Re: [firebird-support] Trying to save the current record before updating... |
---|---|
Author | Helen Borrie |
Post date | 2005-07-13T07:53:31Z |
At 07:05 AM 13/07/2005 +0000, you wrote:
which there is one for each defined column in the current row. There is no
"OLD.*".
Your first syntax is flaky, because you're not actually SELECTING anything.
INSERT INTO INVOICE_LOG (
col1, col2, col3, .... log_date, log_time)
VALUES (:OLD.col1, :OLD.col2, :OLD.col3,......CURRENT_DATE , CURRENT_TIME)
./hb
>Hi all,The OLD values are not database fields, they are context variables, of
>
>I would like to save the current record before updating on a table,
>so I have a Trigger on Update, Before Update:
>
>AS
>BEGIN
> INSERT INTO INVOICE_LOG
> SELECT OLD.* , CURRENT_DATE , CURRENT_TIME
> FROM INVOICE INV
> WHERE INV.ID = OLD.ID ;
>END
>
>This works OK, however shouldn't it be:
>
>
>AS
>BEGIN
> INSERT INTO INVOICE_LOG
> VALUES OLD.* , CURRENT_DATE , CURRENT_TIME ;
>END
>
>Of course this one does not work, So I am trying to understand why?
>
>ISC ERROR CODE:335544569
>ISC ERROR MESSAGE:
>Dynamic SQL Error
>SQL error code = -104
>Token unknown - line 5, char 11
>OLD
which there is one for each defined column in the current row. There is no
"OLD.*".
Your first syntax is flaky, because you're not actually SELECTING anything.
INSERT INTO INVOICE_LOG (
col1, col2, col3, .... log_date, log_time)
VALUES (:OLD.col1, :OLD.col2, :OLD.col3,......CURRENT_DATE , CURRENT_TIME)
./hb