You are here: Re: Trigger Question « MsSQL Server « IT news, forums, messages
Re: Trigger Question

Posted by MGFoster on 04/21/06 21:31

mike wrote:
> I have a SQL based ERP package. Now I am having an issue on a
> particular table of people deleting a record (in the ERP system) and no
> one having any idea of who did it or when.
>
> So I thought I would setup a delete trigger so that when a record is
> deleted from a table it would populate a new table that I created with
> some information, doc_no, date etc... My problem is how can I get the
> new table to populate only information for the record being deleted.
>
> I did one try and it populated it with all remaining records. Ok I see
> my logic error, but realized that I don't know how or if I can populate
> it with info from the record being deleted.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Have you tried the deleted derived table?

CREATE TRIGGER WhoDeleted
ON erp_table FOR DELETE
AS
INSERT INTO audit_table (user_name, doc_no, delete_date)
SELECT CURRENT_USER, doc_no, CURRENT_TIMESTAMP
FROM deleted
GO
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBREkk74echKqOuFEgEQJupgCfUIt6dnQ/LIU5IKEZVwQXtnCCmwAAoLG8
QbqJCqJGaxnk7MbuUesxJlXt
=eI+m
-----END PGP SIGNATURE-----

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация