27.14 GET_DATE Function

This function returns a date member value.

Syntax

APEX_JSON.GET_DATE (
    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_default          IN DATE     DEFAULT NULL,
    p_format           IN VARCHAR2 DEFAULT c_date_iso8601,
    p_values           IN t_values DEFAULT g_values )
RETURN DATE;

Parameters

Table 27-12 GET_DATE 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_default

The default value if the member does not exist.

p_format

The date format mask.

p_values

Parsed JSON members. The default is g_values.

Returns/Raised Errors

Table 27-13 GET_DATE Function Returns and Raised Errors

Return Description

DATE

.Returns the date.

VALUE_ERROR

Raises this error if p_values(p_path) is not a date.

Example

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

DECLARE 
    j apex_json.t_values; 
BEGIN 
    apex_json.parse(j, '{ "items": [ 1, 2, { "foo": "2014-04-29T10:08:00Z" }] }'); 
    
dbms_output.put_line(to_char(apex_json.get_date(p_path=>'items[%d].foo',p0=>3, p_values=>j), 'DD-Mon-YYYY')); 
END;