Subject | RE: [firebird-support] Re: Timestamp - trigger |
---|---|
Author | Dion |
Post date | 2006-02-05T23:02:31Z |
Thanks.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Adam
Sent: 06 February 2006 12:59 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Timestamp - trigger
that in mind, some things may work in iSQL but not IBExpert and vice
versa.
This must be a before insert trigger if you want to change or set any
values. If you want it to run after your other before insert triggers
on the table, then use POSITION 1 (or 2 or 3 or 100, whatever).
at the end of the line. The second error on the above line is that you
should only use single quotes around 'NOW'.
If you use iSQL, then the default terminator is ;. You will need to
change this to something else when adding a trigger though or it will
get confused.
So quickly rewriting it so it works:
SET TERM ^ ;
CREATE TRIGGER SMSQ_RecDateIns FOR SMSQ
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
New.receivedate = cast('NOW' as timestamp);
END
^
SET TERM ; ^
COMMIT WORK;
Adam
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Adam
Sent: 06 February 2006 12:59 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Timestamp - trigger
> I get an "Unknow token – end" here. I am using ISQL(IBExpert) tocreate this
> trigger. I want to insert a timestamp when a record is inserted intoSMSQ
> table.First things first, IIRC IBExpert has an emulator for iSQL so keep
that in mind, some things may work in iSQL but not IBExpert and vice
versa.
>Stop there. You can't edit values AFTER INSERT!!!!
>
>
> CREATE TRIGGER SMSQ_RecDateIns FOR SMSQ
>
> ACTIVE AFTER INSERT POSITION 0
>
This must be a before insert trigger if you want to change or set any
values. If you want it to run after your other before insert triggers
on the table, then use POSITION 1 (or 2 or 3 or 100, whatever).
> ASAbove is the error message you are encountering. It wants a semi colon
>
> begin
>
> /* Trigger text */
>
> New.receivedate = cast("NOW" as timestamp)
>
at the end of the line. The second error on the above line is that you
should only use single quotes around 'NOW'.
> endDon't forget to put the terminator character after the end statement.
>
If you use iSQL, then the default terminator is ;. You will need to
change this to something else when adding a trigger though or it will
get confused.
So quickly rewriting it so it works:
SET TERM ^ ;
CREATE TRIGGER SMSQ_RecDateIns FOR SMSQ
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
New.receivedate = cast('NOW' as timestamp);
END
^
SET TERM ; ^
COMMIT WORK;
Adam
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006