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

查看:39
本文介绍了如何发送参数以在 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天全站免登陆