Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Posts
    12

    Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    So, what exactly is your problem?

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    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(...)

  4. #4
    Join Date
    May 2011
    Posts
    12
    wat is date_format equivalent in db2??

  5. #5
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by adodb21 View Post
    wat is date_format equivalent in db2??
    u don nid it

Posting Permissions

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