drop table t;
create table t(n number, client_id varchar2(30) not null);
create or replace trigger t_iuc for insert or update on t
compound trigger
cli varchar2(30);
before statement is
begin
cli := SYS_CONTEXT('userenv', 'CLIENT_IDENTIFIER');
end before statement;
before each row is
begin
:new.client_id := cli;
end before each row;
end;
/
exec dbms_session.set_identifier('rafu')
insert into t(n) select level from dual connect by level < 4;
select * from t;
1 rafu
2 rafu
3 rafu
2012-01-10
Using client identifier to populate a column
Earlier I wrote about missing dbms_session.get_client_identifier. Here is a compound trigger example using session client identifier to populate a column in a table.
Subscribe to:
Post Comments (Atom)
About Me
- Rafu
- I am Timo Raitalaakso. I have been working since 2001 at Solita Oy as a Senior Database Specialist. My main focus is on projects involving Oracle database. Oracle ACE alumni 2012-2018. In this Rafu on db blog I write some interesting issues that evolves from my interaction with databases. Mainly Oracle.
No comments:
Post a Comment