Subject Declare variables in trigger.
Author Julio César Carrascal Urquijo
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

create trigger BsCompanyPopulate for Company
active after insert position 0
declare variable
AdminsGroupId as numeric(18,0)

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);

The "declare variable... " statement generates an error. Is it
possible o will I have to call a SP with that code?


Julio César Carrascal Urquijo