October 26, 2007 at 7:47 am
Hi,
I'd like to have the ids or another column of rows I just updated. Is it possible?
These columns are necessary to the subsequent insert on another table (an history table...).
Example:
UPDATE AF_Faldone SET Status = 1 WHERE (IDSito = @idSito)
then:
EXEC @error = ArchivioFaldoni_InsertStorico @codiceFaldone, @utente, @archiviatore, "Eliminazione", null;
where @codiceFaldone has to be all the ids just updated...
Some suggestions?
October 26, 2007 at 7:51 am
Have a look at triggers:
http://msdn2.microsoft.com/en-us/library/ms189799.aspx
Regards,
Andras
October 26, 2007 at 8:06 am
Yes, I knows the trigger solution but I would prefer something else if it exists, otherwise goes on trigger...
Tnx
October 26, 2007 at 8:13 am
I do not think anything else is available in SQL Server; triggers, while they should not be overused, are however exactly for this purpose. But maybe it is worth to take a step back, maybe the use of triggers can be avoided. If you describe what you would like to achieve I'm sure we can help 🙂
Andras
October 26, 2007 at 8:30 am
Till now this is my solution (partial code):
IF (@error = 0)
BEGIN
-- elimino i faldoni associati al sito
UPDATE AF_Faldone SET Status = 1 WHERE (IDSito = @idSito)
SET @error = @@ERROR
END
IF (@error = 0)
BEGIN
-- inserisco l'operazione nello storico
INSERT INTO AF_Storico (IDFaldone, Data_Operazione, Utente, Archiviatore, IDTipo_Operazione)
SELECT IDFaldone, GETDATE(), @gestoreArchivio, @gestoreArchivio, @operazione
FROM AF_Faldone WHERE (IDSito = @idSito)
SET @error = @@ERROR
END
All inside transaction.
Something better?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply