Subject | Re: [firebird-support] Computing column in BEFORE INSERT trigger: SOLVED |
---|---|
Author | Alec Swan |
Post date | 2010-12-21T21:35:58Z |
Never mind, I forgot to specify when to execute the trigger. Here is a
working version:
SET TERM ^; -- set delimiter
CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
before insert or update
AS BEGIN
NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
END ^
SET TERM ;^ -- back to normal
working version:
SET TERM ^; -- set delimiter
CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
before insert or update
AS BEGIN
NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
END ^
SET TERM ;^ -- back to normal
On Tue, Dec 21, 2010 at 2:33 PM, Alec Swan <alecswan@...> wrote:
> I am using Firebird 2.5. I execute the following statement in Flamerobin
> 0.9.3:
>
> SET TERM ^; -- set delimiter
>
> CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
> AS BEGIN
> NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
> END ^
> SET TERM ;^ -- back to normal
>
> And get the following error:
>
> Preparing query: -- set delimiter
>
> CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
> AS BEGIN
> NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
> END
> Error: *** IBPP::SQLException ***
> Context: Statement::Prepare( -- set delimiter
>
> CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
> AS BEGIN
> NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
> END )
>
> Message: isc_dsql_prepare failed
>
> SQL Message : -104
> Invalid token
>
> Engine Code : 335544569
> Engine Message :
> Dynamic SQL Error
> SQL error code = -104
> Token unknown - line 3, column 1
> AS
>
>
> Total execution time: 0.004s
>
>
>
> On Tue, Dec 21, 2010 at 2:06 PM, Michael Ludwig <milu71@...> wrote:
>
>>
>>
>> Alec Swan schrieb am 21.12.2010 um 13:50 (-0700):
>>
>> > Michael, setting delimiter did not fix the problem.
>>
>> It works fine in Firebird 2.5.
>>
>> You haven't told us your version yet.
>> --
>> Michael Ludwig
>>
>>
>
>
[Non-text portions of this message have been removed]