Triggers and USER
Posted in 1995
Topics: Server Administration, Triggers, Constraints & Referential Integrity, Platform-Specific Issues
Can anbody explain why, when a table has a default value of USER,
and a trigger inserts into the table, the USER is the owner of the trigger,
but not the USER who activates the trigger.
Try the following :
----------------------------------------
dbaccess ti_test << !
drop table mawb;
drop table mawb_log;
create table "gisadm".mawb
(
mawb_no char(13),
ship_mode char(2),
update_user char(8),
update_time datetime year to minute
);
create table "gisadm".mawb_log
(
mawb_from char(13),
mawb_to char(13),
mode_from char(2),
mode_to char(2),
update_user char(8) default user,
update_time datetime year to minute default CURRENT year to minute
);
create trigger "gisadm".mawb_mode update of mawb_no,ship_mode
on "gisadm".mawb referencing old as pre new as post
for each row
when (((post.mawb_no != pre.mawb_no ) OR (post.ship_mode
!= pre.ship_mode ) ) )
(
insert into "gisadm".mawb_log (mawb_from,mawb_to,
mode_from,mode_to) values (pre.mawb_no ,post.mawb_no
,pre.ship_mode ,post.ship_mode ));
insert into mawb values ('1','OC',USER,CURRENT);
update mawb set mawb_no = '2', ship_mode = 'AX';
insert into mawb_log (mawb_from,mawb_to, mode_from,mode_to)
values ('A' ,'B' ,'01' ,'02' );
select * from mawb_log;!
----------------------------------------
The result is :
mawb_from mawb_to mode_from mode_to update_user update_time
1 2 OC AX gisadm 1995-11-24 08:32
A B 01 02 tilh 1995-11-24 08:32
Why is the value of the first update_user gisadm ??
Is this one of informix's famous "feature bug" ?
Informix and O/S :
HP-UX mars A.09.04 C 9000/856
DB-Access Version 5.03.UC5X1
INFORMIX-SQL Version 4.11.UC1
RSAM Version 5.03.UC5X1 -- On-Line -- Up 102 days 21:04:38 -- 5808 Kbytes
--------------------------------
Ti Lian Hwang
email : tilh@sin-co.SG.DHL.COM
--------------------------------