Reputation: 37895
I have an Update Trigger that logs table changes to a log table.
In the log table, there is a column which stores the type of change made, ie, an Insert or an Update.
I then have a LogType table with three rows, one row for 'Update' and one for 'Insert' and one for 'Deleted' with Id's of 1, 2, 3.
In the update trigger, and hardcode the value of 2 when I insert into the log table. But this seems to the coder in me a poor practice.
The only alternate I can think of to this is having a "Key" column in the LogType table, and then having the 'Key' of 'UPDATE' Then this would get hardcoded into the Updated Trigger.
But is there any advantage to this? Is there any other way to resolve this? As a C# programmer, I would use an enum, but this is no such concept in Sql.
Greg
Upvotes: 0
Views: 118
Reputation: 10327
I don't see a problem in what you are proposing, I use triggers to maintain a history table but instead if a numerical value I use a single char: 'I', 'U' or 'D' as then there's no need to have a lookup/enum to remember which value is which operation.
Upvotes: 1