我有一个字符串包含逗号分隔的字符串在java..我正在传递到一个sql过程正在调用java...这里是java字符串的示例:
String codeString = "'232/232','34fd/34//'";
i的sql db2中的代码:
create procedure history (in id varchar (3), in code varchar (2000))
......
......
begin
insert into table1
select date_from, date_to, code
from table2
where table2.serial= id
and table2.status not in (code);
end
此sql过程正在table1.code中插入相同的字符串,但未排除table2.status在in子句中。
正在table 1中插入值。代码为'232/232','34 fd/34//'(包括所有单引号和逗号)
3条答案
按热度按时间omtl5h9j1#
你在这里说什么:
就等于说:
你不是在说
原因是它是针对整个
code
检查status
,而不是针对code
的某个部分。code
中的逗号分隔列表不会被解析。事实上,不会解析任何变量。它们是完整的。如果您希望in
predicate 中有多个值,则需要多个文字值、多个变量或它们的某种组合。它适用于insert,因为它只是将
code
的整个值插入到table1
的列中,不需要解析。另一个选择,因为你是在一个过程中,是把逗号分隔的列表自己解析成一个字符串数组(这里不会给你展示),然后使用一个集合派生表把数组转换成一个表,你可以在
in
predicate 中使用,如下所示:6za6bjd02#
尝试类似这样的事情:
jexiocij3#
用于i的DB2 V7.4
对于SQL:
对于RPG: