Oracle 11g SOA Suite 数据库适配器接受列表作为输入

发布于 2024-12-11 13:24:18 字数 377 浏览 0 评论 0原文

我希望能够使用 Oracle 11g SOA Suite 数据库适配器创建一个以列表作为输入的服务。所以我希望能够为 getCountries 操作提供一个countryId 列表。

我发现这个 链接。它可以工作,但它会破坏包含分隔字符的参数,因此它并不理想。

我一直在尝试使用一个具有集合作为输入和输出的函数,并使用 for-each 构造来进行映射。但无法让它发挥作用。我不确定 DBAdapeter 是否可以处理这个问题。

有人尝试过这样的事情吗?

I would like to be able to create a service with Oracle 11g SOA Suite Database Adapter that takes a list as input. So I would like to be able to feed the getCountries operation a list of countryId.

I found this link. It works but it breaks on a parameter that contains the delimiting character so it's not ideal.

I've been trying to use a function that has a collection as input and as output and use for-each constructs to do the mapping. But can't get it to work. I'm not certain if DBAdapeter can handle this.

Has anybody tried something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

节枝 2024-12-18 13:24:18

您可以这样做 - 将该参数 (pCountryList) 设置为字符串。

为了使其工作,您需要将列表作为有效的 XML 文档提供

<?xml version="1.0"?>
<Countries>
<Country><ID>MyCountyID 01</ID></Country>
<Country><ID>777</ID></Country>
<Country><ID>ID__3</ID></Country>
</Countries>

然后您需要创建一个带有子选择的查询,将 XML 转换为行(每行包含 XML 中的一个国家/地区 ID)

SELECT * FROM MyTable WHERE CountryID IN
(
SELECT extractvalue(column_value, '/Country/ID') ContryID
FROM TABLE(XMLSequence(XMLTYPE(:pCountryList).extract('/Countries/Country'))) t);

该查询采用国家/地区 ID 列表(打包到 XML 字符串中)并且可以与 Oracle 11g SOA Suite 数据库适配器一起使用。

You can do that - make that Parameter (pCountryList) a string.

To make it work you need to supply the list as a valid XML document

<?xml version="1.0"?>
<Countries>
<Country><ID>MyCountyID 01</ID></Country>
<Country><ID>777</ID></Country>
<Country><ID>ID__3</ID></Country>
</Countries>

Then you need to create a query with a subselect that transforms the XML into rows (each row containing one country ID from the XML)

SELECT * FROM MyTable WHERE CountryID IN
(
SELECT extractvalue(column_value, '/Country/ID') ContryID
FROM TABLE(XMLSequence(XMLTYPE(:pCountryList).extract('/Countries/Country'))) t);

This query takes a list of country IDs (packaged into an XML string) and can be used with Oracle 11g SOA Suite Database Adapter.

荒路情人 2024-12-18 13:24:18

当将参数指定为分隔字符串时,还有另一种可能的方法,例如:

其中#parameter是简单分隔字符串:“'1,2,3,4,5,6,7,8,9,10 '"

SELECT UA, UB FROM CU WHERE UA in ( SELECT SUBSTR ( STRING_TO_TOKENIZE , DECODE(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) , INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL) - 解码(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ) FROM ( SELECT #参数 || ',' AS STRING_TO_TOKENIZE , ',' AS DELIMITER FROM DUAL ) CONNECT BY INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL)>0 )

技巧在于以下子查询,因为它从分隔字符串返回解析的行:

SELECT SUBSTR ( STRING_TO_TOKENIZE , DECODE (级别,1,1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ,
INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL) - 解码(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ) FROM
( SELECT '1,2,3,4,5,6,7,8,9,10' || ',' AS STRING_TO_TOKENIZE , ',' AS DELIMITER FROM DUAL ) CONNECT BY INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL )>0

There is another possible way when giving parameter as delimited string for example:

where #parameter is simple delimited String: "'1,2,3,4,5,6,7,8,9,10'"

SELECT U.A, U.B FROM C U WHERE U.A in ( SELECT SUBSTR ( STRING_TO_TOKENIZE , DECODE(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) , INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL) - DECODE(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ) FROM ( SELECT #parameter || ',' AS STRING_TO_TOKENIZE , ',' AS DELIMITER FROM DUAL ) CONNECT BY INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL)>0 )

The trick is in the following sub-query as it returns parsed rows from delimited string:

SELECT SUBSTR ( STRING_TO_TOKENIZE , DECODE(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ,
INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL) - DECODE(LEVEL, 1, 1, INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL-1)+1) ) FROM
( SELECT '1,2,3,4,5,6,7,8,9,10' || ',' AS STRING_TO_TOKENIZE , ',' AS DELIMITER FROM DUAL ) CONNECT BY INSTR(STRING_TO_TOKENIZE, DELIMITER, 1, LEVEL)>0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文