Trigger Fails to Work

  • Also - If you fire the trigger after UPDATE, your taxid ID will never be anything other than 1.if you were to update the taxID from the UI, the trigger would put it back to 1.

    If you're trying to set a default value - do that outside of the trigger, or restrict this cursor to fire only during INSERT.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thank you. Will do.

  • Kingston Dhasian (3/12/2012)


    jean 93062 (3/12/2012)


    I want to set taxid = 1 to all new records in this table. I also want the user to be able to change the taxid to something else if thats what they want to do. Some items are taxable others are not.

    The taxid remains 0 after this trigger executes. Not one record has a 1 in it.

    You can do this even without using a trigger. Define your column "id" with a default value of 1. If the user wants to change it, he can.

    Maybe I'm missing something but I don't believe theres even a need for a trigger just like Kingston posted earlier. All you need is a DEFAULT value of 1 on the column. User will be able to change it on insert if they want (as part of the requirement IIRC) and if they forget it it will still populate with a 1.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 3 posts - 16 through 17 (of 17 total)

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