我写了下面的代码,这是不显示我想要的输出。我想显示的输出完全一样,我在屏幕截图。我已经创建了REST API在Oracle APEX版本22.2和数据库版本是19 c。
SELECT 'application/json' as content_type, JSON_OBJECT (
KEY 'departments' VALUE (
SELECT JSON_ARRAYAGG(
JSON_OBJECT (
KEY 'department_name' VALUE d.DEPARTMENT_NAME,
KEY 'department_no' VALUE d.DEPARTMENT_ID,
KEY 'employees' VALUE (
SELECT JSON_ARRAYAGG (
JSON_OBJECT (
KEY 'employee_number' VALUE e.EMPLOYEE_ID,
KEY 'employee_name' VALUE e.FIRST_NAME))
FROM OEHR_EMPLOYEES e
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID)))
FROM OEHR_DEPARTMENTS d
where d.DEPARTMENT_ID in (10,20,30)))
AS departments
FROM dual
字符串
的数据
1条答案
按热度按时间mbyulnm01#
我记得这个,我主要是在忘记https://www.thatjeffsmith.com/archive/2017/09/ords-returning-raw-json/的时候使用这个。这里你需要用
{}
作为你列的前缀。在你的查询中,你只需要改变列名:departments
到"{}departments"