print values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • annecarterfredi@gmail.com

    #1

    print values

    I am developing a new trigger and I would like to print Old and New
    values of few columns. I know I can create new table and insert Old
    and New values, but I would like to have simpler solution for this.

    In Oracle,
    DBMS_OUTPUT.PUT _LINE('Old Total wages = ' || TO_CHAR(O.total _wages));
    DBMS_OUTPUT.PUT _LINE('New Total wages = ' || TO_CHAR(N.total _wages));
    would print Old and New values. How to do it in DB2?

    Thanks.

  • annecarterfredi@gmail.com

    #2
    Re: print values

    On Mar 27, 2:02 pm, "annecarterfr.. .@gmail.com"
    <annecarterfr.. .@gmail.comwrot e:
    I am developing a new trigger and I would like to print Old and New
    values of few columns. I know I can create new table and insert Old
    and New values, but I would like to have simpler solution for this.
    >
    In Oracle,
    DBMS_OUTPUT.PUT _LINE('Old Total wages = ' || TO_CHAR(O.total _wages));
    DBMS_OUTPUT.PUT _LINE('New Total wages = ' || TO_CHAR(N.total _wages));
    would print Old and New values. How to do it in DB2?
    >
    Thanks.
    Someone out there might be wonderign why I need this...here is my
    trigger outline:

    CREATE TRIGGER trig.sal_B
    NO CASCADE BEFORE UPDATE OF total_wages, num_of_years
    ON EMP_T
    REFERENCING OLD AS O
    NEW AS N
    FOR EACH ROW
    MODE DB2SQL
    BEGIN ATOMIC
    SET N.commision = (N.total_wages* N.num_of_years/1000.00);
    END
    ;

    I want to verify what would be Old and New values in these scenarios:
    During update of both total_wages, num_of_years
    During update of only num_of_years
    During update of only total_wages

    Thanks.

    Comment

    • Serge Rielau

      #3
      Re: print values

      annecarterfredi @gmail.com wrote:
      On Mar 27, 2:02 pm, "annecarterfr.. .@gmail.com"
      <annecarterfr.. .@gmail.comwrot e:
      >I am developing a new trigger and I would like to print Old and New
      >values of few columns. I know I can create new table and insert Old
      >and New values, but I would like to have simpler solution for this.
      >>
      >In Oracle,
      >DBMS_OUTPUT.PU T_LINE('Old Total wages = ' || TO_CHAR(O.total _wages));
      >DBMS_OUTPUT.PU T_LINE('New Total wages = ' || TO_CHAR(N.total _wages));
      >would print Old and New values. How to do it in DB2?
      >>
      >Thanks.
      >
      Someone out there might be wonderign why I need this...here is my
      trigger outline:
      >
      CREATE TRIGGER trig.sal_B
      NO CASCADE BEFORE UPDATE OF total_wages, num_of_years
      ON EMP_T
      REFERENCING OLD AS O
      NEW AS N
      FOR EACH ROW
      MODE DB2SQL
      BEGIN ATOMIC
      SET N.commision = (N.total_wages* N.num_of_years/1000.00);
      END
      ;
      >
      I want to verify what would be Old and New values in these scenarios:
      During update of both total_wages, num_of_years
      During update of only num_of_years
      During update of only total_wages
      SELECT * FROM NEW TABLE(UPDATE ....)

      :-)

      If you insist on DBMS_OUTPUT style logging. I propose to write said
      stored procedure in SQL and log to a DECLARE GLOBAL TEMPORARY TABLE ..
      NOT LOGGED ON ROLLBACK PRESERVE ORWS ON COMMIT PRESERVE ROWS.

      Cheers
      Serge

      --
      Serge Rielau
      DB2 Solutions Development
      IBM Toronto Lab

      Comment

      • Knut Stolze

        #4
        Re: print values

        Serge Rielau wrote:
        annecarterfredi @gmail.com wrote:
        >On Mar 27, 2:02 pm, "annecarterfr.. .@gmail.com"
        ><annecarterfr. ..@gmail.comwro te:
        >>I am developing a new trigger and I would like to print Old and New
        >>values of few columns. I know I can create new table and insert Old
        >>and New values, but I would like to have simpler solution for this.
        >>>
        >>In Oracle,
        >>DBMS_OUTPUT.P UT_LINE('Old Total wages = ' || TO_CHAR(O.total _wages));
        >>DBMS_OUTPUT.P UT_LINE('New Total wages = ' || TO_CHAR(N.total _wages));
        >>would print Old and New values. How to do it in DB2?
        >>>
        >>Thanks.
        >>
        >Someone out there might be wonderign why I need this...here is my
        >trigger outline:
        >>
        >CREATE TRIGGER trig.sal_B
        >NO CASCADE BEFORE UPDATE OF total_wages, num_of_years
        >ON EMP_T
        >REFERENCING OLD AS O
        > NEW AS N
        >FOR EACH ROW
        >MODE DB2SQL
        >BEGIN ATOMIC
        > SET N.commision = (N.total_wages* N.num_of_years/1000.00);
        >END
        >;
        >>
        >I want to verify what would be Old and New values in these scenarios:
        >During update of both total_wages, num_of_years
        >During update of only num_of_years
        >During update of only total_wages
        >
        SELECT * FROM NEW TABLE(UPDATE ....)
        >
        :-)
        >
        If you insist on DBMS_OUTPUT style logging. I propose to write said
        stored procedure in SQL and log to a DECLARE GLOBAL TEMPORARY TABLE ..
        NOT LOGGED ON ROLLBACK PRESERVE ORWS ON COMMIT PRESERVE ROWS.
        Alternatively, use a UDF as is described here: http://tinyurl.com/lu4wg

        --
        Knut Stolze
        DB2 z/OS Utilities Development
        IBM Germany

        Comment

        Working...