如何发送参数以在Oracle中触发 [英] how to send parameters to trigger in Oracle

查看:164
本文介绍了如何发送参数以在Oracle中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的是向Web应用程序中的当前用户ID等触发器发送额外信息。由于使用了连接池,并且所有连接都使用相同的用户ID,如何将原始Web用户ID传递给触发器?它是一个基于java的应用程序。

The purpose is to send extra information to triggers like current user id from a web application. Since a connection pool is used, and same user id is used for all connections how do I pass the original web user id to trigger? It is a java based application.

推荐答案

如果您无法触摸应用程序代码,并且应用程序本身未传递此信息已经到了数据库,你陷入了僵局。将该信息提供给后端代码的唯一方法是让中间层传递它。

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为应用程序提供了多种传递信息的方法中间层到后端但必须构建应用程序才能利用它们。 DBMS_APPLICATION_INFO 包有一个 set_client_info 过程,该过程允许中间层传递您的后端触发器可以使用的中间层用户的名称查询。如果你想要更通用的话,你也可以使用 Oracle上下文机制。但是,这些方法中的任何一种实际上都要求编写Java应用程序,以便在从连接池中检索连接时将此信息传递给后端。

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.

这篇关于如何发送参数以在Oracle中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆