Thursday, February 9, 2012

advice on what is possible in a stored procedure

Hi
I am about to write my first strored procedure and would appreciate some
advice.
Can anyone tell be if the following is feasible.
I have a record in a database that a user updates over a web interface. The
updated record is sent back to the MSDE database.
I would like to use a trigger event to prevent the original record from
being changed and instead create a new record with the updated information.
The 'inuse' flag of the original record would be set to false, and set to
true for the new record.
What I would like to do is in the Trigger call a stored procedure which
creates the new record and then cancels the original update. Can this be
done?
Also can I pass the contents of the virtual table 'inserted' to a stored
procedure? If I can, can I pass them 'as one' into a custom type in my
stored procedure or will I have to pass each of the fields in inserted
individually to the stored procedure.
Thanks
June
Consider that a trigger is simply a stored procedure. The on update trigger
can do whatever you want it to--including adding or changing rows in the
same or other tables.
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"June Macleod" <junework@.hotmail.com> wrote in message
news:%23dgXdylaEHA.4092@.TK2MSFTNGP10.phx.gbl...
> Hi
> I am about to write my first strored procedure and would appreciate some
> advice.
> Can anyone tell be if the following is feasible.
> I have a record in a database that a user updates over a web interface.
The
> updated record is sent back to the MSDE database.
> I would like to use a trigger event to prevent the original record from
> being changed and instead create a new record with the updated
information.
> The 'inuse' flag of the original record would be set to false, and set to
> true for the new record.
> What I would like to do is in the Trigger call a stored procedure which
> creates the new record and then cancels the original update. Can this be
> done?
> Also can I pass the contents of the virtual table 'inserted' to a stored
> procedure? If I can, can I pass them 'as one' into a custom type in my
> stored procedure or will I have to pass each of the fields in inserted
> individually to the stored procedure.
> Thanks
> June
>

No comments:

Post a Comment