2

I want to work with json data, in an Oracle database, so I tried the apex_json package.

I tried this example from Oracle:

DECLARE
  s varchar2(32767) := '{ "a": 1, "b": ["hello", "world"]}';
BEGIN
  apex_json.parse(s);
  sys.dbms_output.put_line('a is '||apex_json.get_varchar2(p_path => 'a'));
END;

But I get this error:

APEX_JSON.parse must be declared.

How can I verify that APEX_JSON is installed on my db_server? Is there anything I need to do to activate it?

Xyz
  • 5,955
  • 5
  • 40
  • 58
Kresten
  • 810
  • 13
  • 36
  • 2
    Please check [this](https://stackoverflow.com/a/45912298/7998591) ,you are probably using an older APEX version. Also, what's your Oracle database version? There are other functions like [JSON_VALUE](https://docs.oracle.com/database/121/SQLRF/functions093.htm) in 12c+ for parsing / extracting JSON elements – Kaushik Nayak Dec 12 '18 at 15:24
  • Version is 12.1.0.1.0 – Kresten Dec 12 '18 at 15:34

2 Answers2

1
  1. Login as sysdba

  2. Execute the script below:

    select comp_name, version, status from dba_registry where comp_id='APEX';

    It shows all details.

sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
0

You should consider upgrading Oracle to 12.1.0.2 or higher, where JSON_VALUE is available.

SET SERVEROUTPUT ON
DECLARE
  s varchar2(32767) := '{ "a": 1, "b": ["hello", "world"]}';
  l_a INT;
BEGIN
  l_a := json_value(s,'$.a');
  dbms_output.put_line('a is '||l_a);
END;
/

a is 1


PL/SQL procedure successfully completed.
Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45