简体   繁体   中英

Execute stored procedure in a trigger

I do not know if its possible... if not give any idea to achieve this situation.

Let me explain what I want to do:

I want to fire trigger after insert to execute procedure then this procedure will read data from selected table name by user and store it into another table.

First I have an application that reads 2 values from user something like:

Read_From  For_Month

And Read_From contains 3 values

(1) Read From Employees
(2) Read From Entity
(3) Read From Salaries

And For_Month the user select a date

Employees table:

Emp_ID  EMP_NAME  EMP_SHARE   FOR_MONTH
---------------------------------------  
 121     Salim     25.8      01/06/2015

I want to fire trigger after click add button in my application.

So, this trigger will store entered values by user and pass it to procedure for execution, then the procedure will be execute based on these values to read from which table? And for which month?

If it's possible I need this trigger and procedure guys

I'm not sure I fully understand your needs, but here is what I think...

Here, I'm assuming that you have your client (Web) application, some middleware/server-side logic (say a SERVLET) that is approached by your application, and the DB behind the middleware.

First, you don't trigger things within the DB by clicking on a button of your Web application. What you do, is to invoke a stored procedure that performs some actions.

You can proceed in one of two ways:

  1. The stored procedure you invoke when clicking on the button performs the insert and invokes the additional logic that needs to run using the inserted data

  2. You create a trigger on the table into which the data needs to be inserted, where this trigger invokes the logic that needs to be executed using the inserted data. The stored procedure you invoke when clicking on the button will just insert the new data (and, due to the trigger, the additional logic will be executed).

Hope this is what you were looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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