Damo
Damo

Reputation: 51

json_object_t : ORA-30625: method dispatch on NULL SELF argument is disallowed

Im getting an exception when I run the below code in oracle database, how to handle it, pl help

Error report - ORA-30625: method dispatch on NULL SELF argument is disallowed ORA-06512: at line 7 30625. 00000 - "method dispatch on NULL SELF argument is disallowed" *Cause: A member method of a type is being invoked with a NULL SELF argument. *Action: Change the method invocation to pass in a valid self argument.

declare
m_top_obj               json_object_t;
m_paymentDetails_obj    json_object_t;
begin
m_top_obj := json_object_t.parse('{"reference": "hello"}');
m_paymentDetails_obj := m_top_obj.get_object('paymentDetails');
DBMS_OUTPUT.PUT_LINE(m_paymentDetails_obj.get_string('reference'));
end;
/

Upvotes: 0

Views: 1854

Answers (1)

Chris Saxon
Chris Saxon

Reputation: 9875

There's no paymentDetails attribute in the JSON, so m_paymentDetails_obj is null.

Check this before trying to access attributes in it:

declare
  m_top_obj               json_object_t;
  m_paymentDetails_obj    json_object_t;
begin
  m_top_obj := json_object_t.parse('{"reference": "hello"}');
  m_paymentDetails_obj := m_top_obj.get_object('paymentDetails');
  if m_paymentDetails_obj is not null then
    DBMS_OUTPUT.PUT_LINE(m_paymentDetails_obj.get_string('reference'));
  else 
    dbms_output.put_line ( 'no paymentDetails' );
  end if;
end;
/
no paymentDetails

Upvotes: 1

Related Questions