SQL - Trigger
Posted in 2000
Topics: Triggers, Constraints & Referential Integrity
Hi, I have trigger on insert. Is this possible to change (by this trigger) 1 column in record which is inserted? Thanks for all answers Tom
Tom wrote:
> Hi,
>
> I have trigger on insert. Is this possible to change (by this trigger) 1
> column in record which is inserted?
> Thanks for all answers
>
> Tom
CREATE PROCEDURE junk_nulls(l_test_id int, l_prd_cd char(2))
RETURNING char(1); IF l_test_id < 5 THEN
RETURN "A";
ELSE
RETURN "B";
END IF;
END PROCEDURE;
create table junk
(
test_id serial not null ,
prd_cd char(2) not null
);
create trigger tins_junk insert on junk referencing new as postfor each row
when (post.prd_cd is null)
(execute procedure junk_nulls(post.test_id, post.prd_cd) into prd_cd);
insert into junk values (0,null);
insert into junk values (0,null);
insert into junk values (0,null);
insert into junk values (0,null);
insert into junk values (0,null);
insert into junk values (0,'C');
insert into junk values (0,null);
select * from junk;
drop table junk;
drop PROCEDURE junk_nulls;
Rudy