hi all,
I am still struggling to find working example(s) for Master-Detail CRUD implementation using RESTful service.
kindly help with Link(s) or guide here, easy enough to understand by a beginner.
with kind regards
I tried like this searched on internet, need help for a better and recommended way to handle Master-Detail DML operations using RESTful API's.
https://forums.oracle.com/ords/apexds/post/apex-24-1-generate-data-and-deploy-master-detail-crud-using-8981#comment_65352832459507726261493821265796554246
== ===============================================================
== example to generate Master-Detail JSON format data for 2 tables:
== ===============================================================
SELECT 'application/json' as content_type, JSON_OBJECT (
KEY 'department' VALUE (
SELECT JSON_ARRAYAGG(
JSON_OBJECT (
KEY 'dname' VALUE d.DNAME,
KEY 'dept_no' VALUE d.DEPTNO,
KEY 'employees' VALUE (
SELECT JSON_ARRAYAGG (
JSON_OBJECT(
KEY 'empno' VALUE e.EMPNO,
KEY 'ename' VALUE e.ENAME
)
)
FROM EMP e
WHERE e.DEPTNO = d.DEPTNO
)
)
)
FROM DEPT d
where d.DEPTNO in (10,20,30)
)
) AS departments
FROM dual;
== =================================
== Output of above PL/SQL statement:
== =================================
{
"department": [
{
"dname": "ACCOUNTING",
"dept_no": 10,
"employees": [
{
"empno": 7839,
"ename": "KING"
},
{
"empno": 7782,
"ename": "CLARK"
},
{
"empno": 7934,
"ename": "MILLER"
}
]
},
{
"dname": "RESEARCH",
"dept_no": 20,
"employees": [
{
"empno": 7566,
"ename": "JONES"
},
{
"empno": 7788,
"ename": "SCOTT"
},
{
"empno": 7902,
"ename": "FORD"
},
{
"empno": 7369,
"ename": "SMITH"
},
{
"empno": 7876,
"ename": "ADAMS"
}
]
},
{
"dname": "SALES",
"dept_no": 30,
"employees": [
{
"empno": 7698,
"ename": "BLAKE"
},
{
"empno": 7499,
"ename": "ALLEN"
},
{
"empno": 7521,
"ename": "WARD"
},
{
"empno": 7654,
"ename": "MARTIN"
},
{
"empno": 7844,
"ename": "TURNER"
},
{
"empno": 7900,
"ename": "JAMES"
}
]
}
]
}