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 > translate this trigger to db2..need help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-11, 04:47
adodb21 adodb21 is offline
Registered User
 
Join Date: May 2011
Posts: 12
translate this trigger to db2..need help

BEGIN
if exists(select * from HISDB_OJT2011.seg_billing_encounter as sbe where sbe.encounter_nr = new.encounter_nr and
sbe.bill_dte > str_to_date(concat(date_format(new.date_from, '%Y-%m-%d'), ' ', date_format(new.time_from, '%H:%i:%s')), '%Y-%m-%d %H:%i:%s')) then
call Fail('Cannot insert an accommodation earlier than the latest billing for this encounter!');
end if;
END
Reply With Quote
  #2 (permalink)  
Old 05-17-11, 07:47
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
So, what exactly is your problem?
Reply With Quote
  #3 (permalink)  
Old 05-17-11, 17:29
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Some suggestions.

1) See Information Center or manuals for the syntax of CREATE TRIGGER and general guide.
For example:
IBM DB2 9.7 for Linux, UNIX and Windows Information Center | CREATE TRIGGER statement

2) str_to_date(concat(date_format(new.date_from, '%Y-%m-%d'), ' ', date_format(new.time_from, '%H:%i:%s')), '%Y-%m-%d %H:%i:%s'))
may be replaced by a function
TIMESTAMP(new.date_from , new.time_from)

3) CALl Fail(...) may be replaced by a fnction RAISE_ERROR(...)
Reply With Quote
  #4 (permalink)  
Old 05-17-11, 22:50
adodb21 adodb21 is offline
Registered User
 
Join Date: May 2011
Posts: 12
wat is date_format equivalent in db2??
Reply With Quote
  #5 (permalink)  
Old 05-17-11, 23:14
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by adodb21 View Post
wat is date_format equivalent in db2??
u don nid it
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