【发布时间】:2020-08-18 18:08:32
【问题描述】:
我正在尝试使用 PL/JSON 从 SQL 生成 JSON
declare
customer json_list := json_list();
product json_list;
begin
customer:= json_dyn.executeList('SELECT DISTINCT
A.customer_id,
A.customer_name,
FROM customer A
WHERE A.customer_id = 1');
product := json_dyn.executeList('SELECT DISTINCT
A.product_id,
A.product_name,
FROM sales A
INNER JOIN customer B
ON A.customer_id = B.customer_id
WHERE A.customer_id = 1');
end;
我需要的是加入这两个选择成为一个单一的 JSON,看起来像这样: 在某种程度上,产品是销售关键,产品的价值是产品列表
[
{
"customer_id": 1,
"customer_name": "Customer A",
"product": [
{
"product_id": 5715,
"product_name": "Product A",
},
{
"product_id": 7841,
"product_name": "Product B",
}
]
}
]
有人知道怎么做吗?
【问题讨论】: