Subject RE: [firebird-support] Declare variables in trigger.
Author Chris Donges
I think you need the declare variable after the 'as' but before the 'begin'.

> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Julio
> César Carrascal Urquijo
> Sent: Thursday, 10 August 2006 11:04 AM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] Declare variables in trigger.
>
> Is it possible to declare variables inside a trigger? I need
> to insert some rows and relate those in another table. This
> is what I was
> trying:
>
> create trigger BsCompanyPopulate for Company
> active after insert position 0
> declare variable
> AdminsGroupId as numeric(18,0)
> as
> begin
>
> AdminsGroupId = gen_id(SeqGroupId, 1);
> insert into Group (CompanyId, GroupId, GroupCode, GroupName)
> values (new.CompanyId, GroupId, 'admins',
> 'Administradores');
>
> insert into Access (CompanyId, GroupId, FeatureId)
> values (new.CompanyId, :AdminsGroupId, 1);
> insert into Access (CompanyId, GroupId, FeatureId)
> values (new.CompanyId, :AdminsGroupId, 2); ...
> end;
>
> The "declare variable... " statement generates an error. Is
> it possible o will I have to call a SP with that code?
>
> Thanks
>
> --
> Julio César Carrascal Urquijo
> http://jcesar.f2o.org/
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org 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
>
>
>
>
>