GET_T_NUMBER Function

This function returns the numeric attributes of an array.

Syntax

function get_t_number (
 	    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_number;

Parameters

Table 20-17 GET_T_NUMBER 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 p_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 number.

Table 20-18 GET_T_NUMBER Function Raised Errors

Return Description

VALUE_ERROR

On conversion errors.

Example

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

    declare
         j          apex_json.t_values;
         l_elements apex_t_number;
     begin
         apex_json.parse(j, '{ "foo": [111, 222], "bar": 333 }');
         l_elements := apex_json.get_t_number (
                           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_number (
                           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:111
     2:222
     1:333