GET_T_VARCHAR2 Function

This function returns the varchar2 attributes of an array.

Syntax

function get_t_varchar2 (
    p_path             in varchar2,
    p0                 in varchar2 default null,
    p1                 in varchar2 default null,
    p2                 in varchar2 default null,
    p3                 in varchar2 default null,
    p4                 in varchar2 default null,
    p_values           in t_values default g_values )
    return wwv_flow_t_varchar2;

Parameters

Table 20-19 GET_T_VARCHAR2 Function Parameters

Parameter Description

p_path

Index into p_values.

p[0-4]

Each %N in p_path is replaced by pN and every i-th %s or %d is replaced by the p[i-1].

p_values

Parsed JSON members. The default is g_values.

Returns

Array member values if the referenced t_value is an array. An array with just the referenced value if it's type can be converted to a varchar2.

Raises

Table 20-20 GET_T_VARCHAR2 Function Raised Errors

Return Description

VALUE_ERROR

On conversion errors.

Example

This example parses a JSON and prints the value at position 1.

declare
    j          apex_json.t_values;
    l_elements apex_t_varchar2;
begin
    apex_json.parse(j, '{ "foo": ["one", "two"], "bar": "three" }');
    l_elements := apex_json.get_t_varchar2 (
                      p_values => j,
                      p_path   => 'foo' );
    for i in 1 .. l_elements.count loop
        sys.dbms_output.put_line(i||':'||l_elements(i));
    end loop;
    l_elements := apex_json.get_t_varchar2 (
                      p_values => j,
                      p_path   => 'bar' );
    for i in 1 .. l_elements.count loop
        sys.dbms_output.put_line(i||':'||l_elements(i));
    end loop;
end;

Output:
  1:one
  2:two
  1:three