1 Reply Latest reply: Aug 5, 2008 8:12 AM by 637104 RSS

    How to format a field?

    652910
      Hi,

      I'm quite new to Oracle Reports and probably my question is quite stupid...

      I have a tabular report and want to add a String to each field of one column.
      From the database, I get a list of frequencies and I don't want to display just the number but want to add 'kHz' to the field.

      The next step would be to determine if the frequency is greater than 1000kHz , then I want to convert the display to '1 MHz'.

      Has anyone an advice how to do this?

      Best regards,
      Florian
        • 1. Re: How to format a field?
          637104
          Hi there,

          Check out the help on format triggers so you understand how they work.

          Then create a format trigger that tests your value and changes the value displayed in the item using the SRW.SET_FIELD_CHAR function.

          e.g.
          FUNCTION CHGFIELD RETURN BOOLEAN IS 
          v_temp_val NUMBER;

          BEGIN
             if :dbvalue >= 1000 then

               v_temp_val := :dbvalue / 1000;
               srw.set_field_char (0, v_temp_val||'KHZ');
             else

               srw.set_field_char (0, :db_value||'HZ');
             end if;
          RETURN (TRUE);
          END;