Search code examples
oracleplsqloracleforms

Take value from one form and pass it to another one


I am started to learn PLSQL Oracle and I tried to find a way to copy value from one form to another. I have two form, first form (A) make some calculation and in some case this calculation cannot be edited in form (A). I came in idea to make form (B) and pass this data from form (A) edit them, and pass it back to form (A) Here is my code and picture of my idea.

begin
    set_block_property('POL',UPDATE_ALLOWED,PROPERTY_TRUE);

        update POL set  
        POLICA =: TENDER.POLICA,
        VOZAC = TENDER.VOZAC,
        BR_VOZACA = TENDER.BR_VOZACA,
    NEZGODA1 = TENDER.NEZGODA1,
        PUTNICI = TENDER.PUTNICI,
        BR_PUTNIKA = TENDER.BR_PUTNIKA,
        NEZGODA = TENDER.NEZGODA,
        AO_PLUS_LIMIT = TENDER.AO_PLUS_LIMIT,
        AO_PLUS_PREMIJA = TENDER.AOPLUSPREMIJA,
        PRAVNA_ZASTITA_LIMIT = TENDER.PRAVNA_ZASTITA_LIMIT,
        PRAVNA_ZASTITA_PREMIJA = TENDER.PRAVNA_ZASTITA_PREMIJA,
        LOM_STAKLA_PREMIJA = TENDER.LOM_STAKLA_PREMIJA,
        TROSKOVI_LIJECENJA = TENDER.TROSKOVI_LIJECENJA,
        TROSKOVI_LIJECENJA_PREMIJA = TENDER.TROSKOVI_LIJECENJA_PREMIJA

        WHERE POLICA =:TENDER.BRPOLICE;

end;

I try option: Copy Value from Item properties but I get error

FRM-30047: Cannot resolve item reference 

I dont know where I made mistake? Any suggestion or comment ??


Solution

  • Forms usually communicate via two following ways:

    • parameter
    • global variable

    A global variable is simpler to use; in form A you simply set it to :global.polica := :pol.polica; and use it in form B as (for example)

    select ...
    from some_table
    where polica = :global.polica;
    

    Global variables are always strings (their datatype is VARCHAR2) whose size is restricted (that might depend on Forms version; I know that certain versions had it restricted to 255 characters).

    A parameter is somewhat more complex to use, as you have to create it first (in Object Navigator's "Parameters" node), but it allows you to choose a datatype (so you aren't restricted to strings only). You set its value just like global variable's one: :parameter.polica := :pol.polica; but you have to actually pass it to form B within CALL_FORM (or OPEN_FORM) parameter list. For example:

    A function which creates parameter list (will be used later in example):

    function make_param_list (p_name in varchar2)
      return paramlist 
    is
      pl_id     paramlist;
      w_button  number;
    begin
      pl_id := get_parameter_list(p_name);
      if not id_null(pl_id) then
         destroy_parameter_list(pl_id);
      end if;
    
      pl_id := create_parameter_list(p_name);
    
      if id_null(pl_id) then
         message('DESIGN ERROR - PARAMLIST');
         if name_in('system.mode') <> 'QUERY' then
            raise form_trigger_failure;
         end if;
      else
         return pl_id;
      end if;
    end;
    

    Example; list_id is related to parameters we're talking about:

    declare
      list_id ParamList;
    begin
      list_id := make_param_list('input_params');
    
      Add_Parameter(list_id, 'ugo_id'         , TEXT_PARAMETER, :ugo.ugo_id);
      Add_Parameter(list_id, 'query_only_mode', TEXT_PARAMETER, :parameter.query_only_mode);
    
      call_form('ugoa', no_hide, no_replace, no_query_only, no_share_library_data, list_id);
    end;
    

    Much more info in Forms Online Help System.