![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
ASA7.0.4 WIN32 Hello, I'm trying to create a trigger that converts a before delete on a row into a valid SQL statement. The SQL statement would return the delete action made on the row. So far, I have come up with a trigger that fakes up an SQL insert to return the record if delete. I store the sql statement in text data type in a table somewhere. At the moment the statement is printed on screen alter trigger DBA.Test_archive before delete order 1 on DBA.MASTER referencing old as old_name for each row begin declare SQLVar char(128); set SQLVar=(select LIST('"' || Syscolumn.column_name || '"') as Column_list from systable join syscolumn on systable.table_id = syscolumn.table_id where table_name = 'MASTER'); print 'INSERT INTO MASTER(' || SQLVar || ')\x0A'+'VALUES(' || old_name."Ref no" || ', ''' || Old_name.name || ''');' end TIA Russell J Morgan |
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi, Sorry for my ambiguity. Essentially I was trying to capture the row before it is deleted. I construct an INSERT Statement around the deleted row, which can be stored into separate table for deleted transactions as text. This keeps an archive of any deleted rows. If the customer ever wants to recover the deleted transaction we can return the record without much effort. I can do all of this, however I was trying to make my life a lot easier by referencing the whole row as one variable. This would essentially make my life a lot easier when in comes to constructing the SQL statement for returning the record if so desired. So my question is: Using a trigger, is there a container for holding the whole row that I may collect and construct an SQL statement around it. Thanks |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |