trigger problem

  • Hello

    I have same problem to create trigger i create two tables 1) is Cusotmer profiles and 2)Customer Buy

    1) Customer profile table consist 4 fields

    CustomerID CustomerName CustomerBalance Status

    02 Jack 4500 Disable

    2) CustmerID Producet Qty TotalAmount

    02 Fish 4 350

    02 Oil 1 150

    i want to create trigger that if Customer profile status field is (Disable).block insert new enter in CustomerBuy table where CustomerID 02

    create trigger block on CustomerBuy

    for insert

    as

    if insert(CustomerBuy.Client)

    begin

    if exists (select status from inserted where status='Enable')

    rollback

    end

  • Three clues...

    1- Triggers are created in a table.

    2- Trigger has to know when to fire - insert? delete? update?

    3- If you want trigger to insert in another table, you have to write insert statement.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

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

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