Oracle 11g SOA Suite 数据库适配器接受列表作为输入
我希望能够使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样做 - 将该参数 (
pCountryList
) 设置为字符串。为了使其工作,您需要将列表作为有效的 XML 文档提供
然后您需要创建一个带有子选择的查询,将 XML 转换为行(每行包含 XML 中的一个国家/地区 ID)
该查询采用国家/地区 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
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)
This query takes a list of country IDs (packaged into an XML string) and can be used with Oracle 11g SOA Suite Database Adapter.
当将参数指定为分隔字符串时,还有另一种可能的方法,例如:
其中#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