Triggers

  • I have an insert trigger and I'm trying to modify one of the inserted tables' column. How can I do that?

    Table name is table_tbl. column name is fname

    Code inside of insert trigger.

    select inserted.fname = select fname from other_tbl where fname='this_is_a_unique_name'

    I'm always getting a syntax error.

  • You cannot update a value in the inserted table. You have to do an UPDATE of the same row based on its primary key from the trigger. Or, better yet, figure out the right value before entering the trigger, i.e., in the INSERT statement itself. To get it from the 'other_tbl' use a JOIN.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply