Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    1

    Unanswered: Trigger/check constraint (urgent)

    hi,
    i have to write trigger or it may be check constraint (if possible)
    about the following conditions..
    i have two table as follows..
    bid table aut_attr table
    --------- --------------
    aut_id bid_price aut_id min_bid_price
    ==== ====== ==== ==========
    1 105 1 100
    2 250 2 200
    3 310 3 300
    4 499 4 400
    both tables are relation on aut_id(pf,fk)
    write a query to insert value in bid_price column of bid table the condition is that it should not be less than min_bid_price fixed value of aut_attr table .before inserting it will check...
    /rkb
    Last edited by raakesh; 08-30-04 at 09:44.

  2. #2
    Join Date
    Aug 2003
    Location
    Massachusetts, USA
    Posts
    106
    Something like this...

    CREATE TRIGGER IB1_bid
    BEFORE INSERT ON bid_table
    REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL
    WHEN (SELECT 1 FROM aut_attr WHERE n.bid_price < min_bid_price
    AND n.aut_id = aut_id0 = 1)
    BEGIN
    SIGNAL SQLSTATE '99999'
    SET MESSAGE_TEXT = 'Bid price less than minimum';
    END;
    @

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •