I have defined associative array in Oracle as below
CREATE OR REPLACE TYPE outlier AS OBJECT (
ACCOUNT_ID varchar2(100),
INC_MONTH date,
);
create or replace type outlier_acc_tab as table of outlier ;
CREATE OR REPLACE TYPE outlier_detail_rec AS OBJECT (
NAME varchar2(100),
OUTLIER_ACCOUNT_LIST outlier_acc_tab
);
create or replace type outlier_detail_tab as table of outlier_detail_rec;
Currently I am getting names repeated in all the OUTLIER_ACCOUNT_LIST array. Instead I want to group multiple account details for a single name. Please let me know how the definition of arrays should be modified. Thanks for your help.
I am looking for an output like this
"OUTLIER_LIST": [
{
"NAME": "A",
"OUTLIER_ACCOUNT_LIST": [{
"ACCOUNT_ID": "361",
"INC_MONTH ": 1475208000000
}
},
{
"ACCOUNT_ID": "362",
"INC_MONTH": 1475208000000,
}
}
]
]
}
My select statement in the package is
SELECT outlier_detail_rec (
NAME => NAME,
outlier_acc_tab (
outlier_acc_rec(
ACCOUNT_ID => ACCOUNT_ID,
INC_MONTH => INC_MONTH
) ))
BULK COLLECT INTO v_outlier_array
FROM outlier_Sel;