Subject | Declare variables in trigger. |
---|---|
Author | Julio César Carrascal Urquijo |
Post date | 2006-08-10T01:04:10Z |
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/
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/