469,575 Members | 1,365 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

Trigger After Delete - I would need a Trigger Before Delete

hello,
I googled around some time but I found no solution for this issue
(SS2000).

I have a table tblB which has to be filled whenever in another table
tblA records are inserted, updated or deleted.
So I created one trigger which works fine for inserts and updates and
fills my tblB. tblB is filled with other fields which I get from a
view vwC.

The issue is about this view. When in tblA a record is deleted, the
corresponding record in vwC does not exist and I can't fill tblB. I
tried around with INSTEAD OF -Trigger and got error message because
tblA has RI cascades so this is not possible. A temp table could be
the right way? Can you show me an example?

thanks
--
candide_sh

Jul 17 '07 #1
1 1567
I believe you will have to do it without the view. You would need the
view to join the DELETED table to those other tables, and no view can
reference DELETED. In the trigger, in the FROM clause, replace the
reference to the view with a derived table using the same SELECT as
the view. So instead of:

FROM ViewName

you will need

FROM (<SELECT.....>) as ViewName

Note that if you have an alias assigned to the view reference that
would go after the "as" rather than ViewName.

Roy Harvey
Beacon Falls, CT

On Tue, 17 Jul 2007 08:04:59 -0700, ca********@yahoo.de wrote:
>hello,
I googled around some time but I found no solution for this issue
(SS2000).

I have a table tblB which has to be filled whenever in another table
tblA records are inserted, updated or deleted.
So I created one trigger which works fine for inserts and updates and
fills my tblB. tblB is filled with other fields which I get from a
view vwC.

The issue is about this view. When in tblA a record is deleted, the
corresponding record in vwC does not exist and I can't fill tblB. I
tried around with INSTEAD OF -Trigger and got error message because
tblA has RI cascades so this is not possible. A temp table could be
the right way? Can you show me an example?

thanks
Jul 17 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matik | last post: by
6 posts views Thread by Scott CM | last post: by
7 posts views Thread by rkrueger | last post: by
reply views Thread by JohnO | last post: by
2 posts views Thread by dean.cochrane | last post: by
6 posts views Thread by Oliver | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.