Reputation: 399
I have the following procedure
CREATE OR REPLACE PROCEDURE GetAddress(P_JSON_CLOB_IN IN CLOB, P_JSON_OBJECT_OUT OUT JSON_OBJECT_T)
AS
V_JSON_OBJ JSON_OBJECT_T := JSON_OBJECT_T.parse(P_JSON_CLOB_IN);
V_ID CUSTOMERS.ID%TYPE;
V_TYPE ADDRESSES.TYPE%TYPE;
V_ADR ADDRESSES%ROWTYPE;
BEGIN
V_ID := V_JSON_OBJ.GET_STRING('id');
V_TYPE := V_JSON_OBJ.GET_STRING('type');
SELECT a.* INTO V_ADR FROM ADDRESSES a
INNER JOIN CUSTOMERS c ON c.ID=a.PEOPLEID
WHERE c.ID = V_ID
AND a.TYPE = V_TYPE;
P_JSON_OBJECT_OUT.put('address1',TO_CHAR(V_ADR.ADDRESS1));
P_JSON_OBJECT_OUT.put('address2',TO_CHAR(V_ADR.ADDRESS2));
P_JSON_OBJECT_OUT.put('zipmask',TO_CHAR(V_ADR.ZIPMASK));
P_JSON_OBJECT_OUT.put('city',TO_CHAR(V_ADR.CITY));
P_JSON_OBJECT_OUT.put('countryCode',TO_CHAR(V_ADR.COUNTRYCODE));
EXCEPTION
WHEN NO_DATA_FOUND THEN
P_JSON_OBJECT_OUT.put('error','NO DATA FOUND');
END;
It compiles successfully, however when invoked returns oracle exception "ORA-30625 Method dispatch on NULL SELF argument is disallowed" on line 21. I assume the error occurs because parameter P_JSON_OBJECT_OUT needs to be initialized prior to adding a key/value? How do I achieve this?
Thanks
Upvotes: 1
Views: 2071
Reputation: 399
I Found the solution. Simply add the following line in the start of the block:
P_JSON_OBJECT_OUT := new JSON_OBJECT_T;
Upvotes: 1