29.32 SET_COMPONENT_VALUES Procedure

This procedure extends Session State to include the column values of a specific row number. By doing so, columns can be referenced using substitution syntax or the V function in the same way as you can reference page or application items.

Note:

Always call apex_plugin_util.clear_component_values after you are done processing the current row!

Syntax

PROCEDURE SET_COMPONENT_VALUES (
    p_column_value_list IN t_column_list,
    p_row_num           IN PLS_INTEGER );

Parameters

Table 29-42 SET_COMPONENT_VALUES Parameters

Parameter Description

p_column_value_list

Table of t_column_values returned by the call to apex_plugin_util.get_data2.

p_row_num

Row number in p_column_value_list for which the column values should be set in Session State.

Example

This example is the skeleton of a simple item type plug-in rendering function which renders a link list based on a provided SQL query. Instead of a fixed SQL query format where the first column contains the link and the second contains the link label, it allows a developer using this plug-in to enter any SQL statement and then use substitution syntax to reference the values of the executed SQL query.

function render_link_list (
    p_item                in apex_plugin.t_page_item,
    p_value               in varchar2,
    p_is_readonly         in boolean,
    p_is_printer_friendly in boolean )
    return apex_plugin.t_page_item_render_result
is 
  -- The link target plug-in attribute 01 would allow that a developer can enter a link which references columns
  -- of the provided SQL query using subsitution syntax.
  -- For example: f?p=&APP_ID.:1:&APP_SESSION.::&DEBUG.::P1_EMPNO:&EMPNO. 
  -- where &EMPNO. references the column EMPNO in the SQL query. 
  c_link_target    constant varchar2(4000) := p_item.attribute_01;
  -- The link label column plug-in attribute 02 would allows a developer to reference a column of the SQL query
  -- which should be used as the text for the link.
  c_link_label_column constant varchar2(128) := p_item.attribute_02;
  --
  l_column_value_list apex_plugin_util.t_column_value_list2;
begin
    l_column_value_list :=
        apex_plugin_util.get_data2 (
            p_sql_statement =>
            ... );
    --
    sys.htp.p('<ul>');
    for i in 1 .. l_column_value_list.count(1)
    loop
        -- Set all column values of the current row
        apex_plugin_util.set_component_values (
            p_column_value_list => l_column_value_list,
            p_row_num           => i );
        --
        sys.htp.p(
            '<li><a href="' ||
            apex_escape.html_attribute( apex_util.prepare_url( c_link_target )) || '">' ||
            apex_escape.html( v( c_link_label_column )) ||
	   '</a></li>');

        --
        apex_plugin_util.clear_component_values;
    end loop;
    sys.htp.p('<ul>');
end;