简体   繁体   English

要在mysql中运行选择查询时自动执行存储过程

[英]execute stored procedure automatically when a select query want run in mysql

I have a application that connected to my database and execute query on it. 我有一个连接到数据库并对其执行查询的应用程序。
Also I have a stored procedure. 我也有一个存储过程。
Now I want every time that application try to execute a query on my database, my procedure run and effect (change) results of application query. 现在,我希望每次该应用程序尝试在数据库上执行查询时,我的过程都会运行并影响(更改)应用程序查询的结果。

Is it possible? 可能吗? And how? 如何?

note that my database is mysql and I can not modify the application code. 请注意,我的数据库是mysql,我无法修改应用程序代码。

You might want to take a look into triggers: 您可能想看看触发器:

http://dev.mysql.com/doc/refman/5.0/en/triggers.html http://dev.mysql.com/doc/refman/5.0/en/triggers.html

-- update -- -更新-

I can think of a different possibility. 我可以想到另一种可能性。 It's ugly: 它很丑:

You could hide your table behind a view by renaming the table and creating a view with it's original name, then manipulate the data in the select statement of the view. 您可以通过重命名表并使用其原始名称创建视图,然后将其隐藏在视图后面,然后在视图的select语句中操作数据。 You just have to be sure the view returns the column names the original query did. 您只需要确保该视图返回原始查询所做的列名即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM