# Miscellaneous > General Database Discussions >  Passing variables within triggers

## Kevy Strong

Does any one know how to pass variables to a stroed procedure within a trigger and does anyone know how to capture a value
from a stored procedure and store that value in a variable all within a trigger.

----------


## Jonathan yang

Unlike SP which is called to execute, trigger rns automatically.  No way to pass variable directly to trigger procedure.

But you can make arround by putting the value to a 1-row-1-column table.
Make sense?

Good luck


On 8/4/98 3:57:07 PM, Kevy Strong wrote: 
> Does any one know how to pass variables to a stroed procedure within a 
> trigger and does anyone know how to capture a value
from a stored 
> procedure and store that value in a variable all within a trigger.

----------


## Don Romano

You can pass and receive data to a stored procedure within a trigger just as you would pass values between any stored procedures.

I`m not sure if you`re asking how to pass in values from outside the trigger into the trigger and then to the stored procedure.   You can not pass parameters to a trigger so where would the trigger get the data to send on as parameters to a stored procedure within the trigger?

You have the INSERTED and DELETED tables to look at to see data that was effected that caused a trigger to fire and you can select and pass that data to a stored procedure within a trigger.

Maybe you can look into the use of global variables... though I have not used them in this case and do not really know how their scope will work... i.e. does the trigger and the stored procedure see your global variables set from somewhere else.   But, hey, it`s worth a shot.  :-)

You can also, obviously, select data from a table from within a trigger and pass that data to a stored procedure.

A bit more info on your question might be helpful if we`re totally missing the point.

From within the trigger... capturing the value (result, output variables) from a stored procedure and storing those values in variables within a trigger should be able to be done as you would do it from one stored procedure to another.

I mean, in my mind... a trigger is the same as any procedure except that it is invoked by an event rather than being specifically called by another procedure but it doesn`t accept parameters.   Probably because 99% of the time the parameters are the values of the data rows of the table that the trigger is based on.

Don


On 8/4/98 3:57:07 PM, Kevy Strong wrote: 
> Does any one know how to pass variables to a stroed procedure within a 
> trigger and does anyone know how to capture a value
from a stored 
> procedure and store that value in a variable all within a trigger.

----------

