I am using Sybase ASE 15.7. I wish to create trigger before insert such that before inserting, I want to modify some fields in the inserted row.
Please help Thanks!
I am using Sybase ASE 15.7. I wish to create trigger before insert such that before inserting, I want to modify some fields in the inserted row.
Please help Thanks!
From a trigger perspective you have a couple options:
for insert
trigger; must be defined against the base table; this trigger will fire after the data has been inserted to the table; the trigger would be coded to perform updates against the base table of the newly inserted rowinstead of
trigger; must be defined against a view (the view would be defined against the base table); you would perform your insert against the view which would cause the instead of
trigger to fire; the trigger would be coded to copy/manipulate the data from the inserted
pseudo-table and write the final data set into the base tableSee create trigger for more details.
Another option would be to write a stored procedure that does all of the pre-insert changes; instead of inserting directly to the base table you would call the stored proc (passing in all of the column values as input parameters). [granted, less than ideal]
'course one other option would be to have the application perform the pre-insert checks and edits before inserting the final data set to the base table.