If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Trigger/check constraint (urgent)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-30-04, 08:42
raakesh raakesh is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
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 08:44.
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 15:45
dmmac dmmac is offline
Registered User
 
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;
@
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On