Re: Triggers and restoring old data.
Posted in 1994
> I must create a program that must insert some old data from tape > into a couple of tables. The trick is that the tables may have > changed slightly; there may be new columns, maybe a column name > change, maybe a column set to "not null". > The first thing I want to do is to deal with the case where a new > "not null" column has been added. I guess I can load the data in > ok but I need to get a default value for the new column from somewhere. > Any hints accepted with my heartfelt appreciation. Try creating a table that has the "old" layout. Create an INSERT trigger for that table. Have that trigger call a stored procedure and pass in all values. Have the stored procedure do all of your checks, modifying the data Load the old data into the old table and the trigger/stored procedure will do the rest Drop the old table. Depending on the size of the table and the number of changes that needs to be done, this can be thrown together in a short period of time. Danni