how to send parameters to trigger in Oracle

夙愿已清 提交于 2019-12-05 14:43:35
Justin Cave

If you can't touch the application code and the application itself does not pass this information to the database already, you're at an impasse. The only way to make that information available to back-end code is for the middle tier to pass it in.

Oracle provides a number of ways for applications to pass information from the middle-tier to the back end but the application has to be built to take advantage of them. The DBMS_APPLICATION_INFO package, for example, has a set_client_info procedure that allows the middle tier to pass in the name of the middle tier user that your back end trigger could query. You can also use Oracle contexts if you want a more general mechanism. Either of these approaches, however, realistically require that the Java application be written to pass this information to the back-end when connections are retrieved from the connection pool.

You can make use of proxy authentication to identify the users even with a ConnectionPool.

An example:

me@XE> @man proxy

[ P R O X Y A U T H E N T I C A T I O N ]

drop user application_user
drop user end_user


-- let's create the application user which all users
-- need to connect through.
-- This user is meant as the middle-tier-user in a
-- multi-tier setup.
create user application_user identified by application_user

-- create an end-user
create user end_user identified by end_user
quota unlimited on users

grant create session, create table to end_user

-- this is the clause to grant access to end_user.
alter user end_user grant connect through application_user

-- now, we can connect WITHOUT PASSWORD!
@connect application_user[end_user]/application_user

-- this should display "END_USER"
select user from dual

-- this should display "APPLICATION_USER"
column proxy_user format a30
select sys_context('userenv', 'proxy_user') proxy_user from dual

http://blogs.oracle.com/jheadstart/entry/using_proxy_authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!