using apexlib to update tabular form columns

2007-10-23
2013-04-22
  • Steve Howard
    Steve Howard
    2007-10-23

    Patrick,

    Can I call pl/sql onchange event when I change a value for a field in a tabular form to set the other field values using apexlib tools - sort of like the following??? Or is there a better way?

    When I try it the error message scolds me about incorrect number of parameters for the V function...

    Thanks,
    Steve

    declare
    t_pr container.preservative_requirement%type;
    t_ct container.container_type%type;
    t_cs container.container_size%type;
    t_noc container.number_of_containers%type;
    t_ht container.holding_time%type;

    BEGIN
        FOR ii IN 1 .. ApexLib_TabForm.getRowCount
        LOOP
            IF ApexLib_TabForm.hasRowChanged(ii, TRUE)
            THEN
                select preservative_requirement,container_type,container_size,
                number_of_containers,holding_time into
                 t_pr, t_ct, t_cs, t_noc, t_ht            
                from container
              Where matrix = ApexLib_TabForm.V ('MATRIX', ii)
              and analytical_method_id = ApexLib_TabForm.V ('ANALYTICAL_METHOD_ID', ii);
    ApexLib_TabForm.V('PRESERVATIVE_REQUIREMENT', ii) := t_pr;
    ApexLib_TabForm.V('CONTAINER_TYPE', ii) := t_ct;
    ApexLib_TabForm.V('CONTAINER_SIZE', ii) := t_cs;
    ApexLib_TabForm.V('NUMBER_OF_CONTAINERS', ii) := t_noc;
    ApexLib_TabForm.V('HOLDING_TIME', ii) := t_ht;
            END IF;
        END LOOP;
    END;

     
    • Patrick Wolf
      Patrick Wolf
      2007-10-26

      Hi Steve,

      sorry for the late reply.

      ApexLib_TabForm.V is just a function. You can't use it to assign a value to a column. But you can use
      ApexLib_TabForm.setValue

      The interface for it is:

      PROCEDURE setValue
        ( pColumnName IN VARCHAR2
        , pRow        IN NUMBER
        , pValue      IN VARCHAR2
        );

      So your code would look like the following:

      ApexLib_TabForm.setValue('PRESERVATIVE_REQUIREMENT', ii, t_pr);
      ApexLib_TabForm.setValue('CONTAINER_TYPE', ii, t_ct);
      ApexLib_TabForm.setValue('CONTAINER_SIZE', ii, t_cs);
      ApexLib_TabForm.setValue('NUMBER_OF_CONTAINERS', ii, t_noc);
      ApexLib_TabForm.setValue('HOLDING_TIME', ii, t_ht);

      Patrick

       
    • Patrick Wolf
      Patrick Wolf
      2007-10-26

      BTW, you should also read my recent posting http://inside-apex.blogspot.com/2007/10/sql-embedded-into-plsql.html about using PL/SQL functions in the WHERE clause.

      Patrick