开发者

Informix JDBC PreparedStatement UPDATE Multiset

开发者 https://www.devze.com 2023-01-22 10:57 出处:网络
I want to change MULTISET column of the table, and my code looks something like this: PreparedStatement pstm = preparedStatement(\"UPDATE table SET mc = MULTISET{?, ?} WHERE ...\");

I want to change MULTISET column of the table, and my code looks something like this:

PreparedStatement pstm = preparedStatement("UPDATE table SET mc = MULTISET{?, ?} WHERE ...");
pstm.setString(1, "...");
pstm.setString(2, "...");
pstm.execute();

And I get error: "Illegal attempt to convert a collection type into another type.".

What is wrong with this? When I put real value开发者_开发百科s instead of '?' everything works just fine.

Btw... mc is defined like MULTISET(CHAR(20) NOT NULL)

Thank you...


I tested it using JDBC Informix drivers 3.50 and Jython 2.5.1 and it works. Maybe you use some old version of JDBC? I tested it both with execute() and executeUpdate() method. My code:

from java.sql import DriverManager
from java.lang import Class

Class.forName("com.informix.jdbc.IfxDriver")

db = DriverManager.getConnection(db_url, usr, passwd)
pstm = db.prepareStatement("UPDATE aaa_mc_test SET mc_test = MULTISET{?, ?}")
pstm.setString(1, "...")
pstm.setString(2, "...")
r = pstm.executeUpdate()
print('ok, updated: %d' % (r))

For 3 records I inserted to aaa_mc_test table it prints out ok, updated: 3

0

精彩评论

暂无评论...
验证码 换一张
取 消