我试图调用一个PLSQL过程,该过程有一个记录(标题)和一个表类型(行)作为输入参数。如果需要,我可以更改该过程,但在一天结束时,我需要创建一个带有标题和行的项目。我在网上看到一些文章,其中一个提到表类型不允许在ORDS中,只允许VARRAYS。这是真的吗?我如何实现这一点,或者有什么工作吗?
我的处理程序源看起来像这样。这是因为记录和表类型没有正确传递而出错。
DECLARE
x_return_code NUMBER;
x_return_msg VARCHAR2(200);
BEGIN
xx.xx_manage_item.create_item( p_req_id => :req_id,
p_header_rec => :header_rec,
p_sf_lines_tab => :lines_tab,
x_return_code => x_return_code,
x_return_msg => x_return_msg);
END;
我的帖子请求如下所示:行可以是多行
{
"req_id":1,
"header_rec":{
"cust_account_id":"123",
"order_type":"XX",
"customer_po":"TestPO2",
"sales_person":"",
"currency_code":"USD",
"end_user_address":"Stockport 12",
"request_date":"09/10/2023"
},
"lines_tab":[
{
"inv_item_id":"112",
"item_name":"",
"quantity":"1",
"uom":"EA",
"plant_number":"w12",
"request_date":"09/10/2023"
}
]
}
Thanks in advance
2条答案
按热度按时间3yhwsihp1#
不要尝试将值拆分为header和lines,只需将整个JSON消息传递给过程并在那里处理它:
例如,您可以像这样创建过程:
然后传递你的信息:
其输出:
fiddle
erhoui1w2#
找到了问题的解决方案。我使用body_text参数将整个JSON捕获为CLOB对象,并将其作为参数传递到我的包中。我在包中解析了完整的JSON。
所以,我们不能在ORDS中使用表类型,但我们可以使用这种方法,所以我们不必这样做。下面是官方文档:
Oracle文档