使用 %SQLGatewayConnection遇到一个奇怪的问题
我用%SQLGatewayConnection把别人给我的数据转为sql 写入mysql的时候,如果数据里面有 ascii 码为57659 这样的数据的时候,
ClassMethod Execute(sql, conn, Output msg) As%Status
{
s$zt="Err"
s msg=""
k hstmt
set sc=conn.AllocateStatement(.hstmt)
set sc=conn.PrepareW(hstmt,sql)
if$$$ISERR(sc) quit sc
//Execute statement
set sc=conn.Execute(hstmt)
if$$$ISERR(sc)
{
k err
Set xsc=conn.GetErrorList(hstmt,.err)
set sc=conn.DropStatement(hstmt)
;Zwrite err
Quit err
}
set sc=conn.DropStatement(hstmt)
q$$$OK
Err
;w $ze,!
q$ze
}这个方法就会一直卡在 set sc=conn.PrepareW(hstmt,sql) 这一行,这时候,sql是一个insert 语句,也不报错,就是一直卡着。有没有什么办法能解决?57659 只是一个例子,还有其他的,比如57634 也不行
Product version: Ensemble 2016.1
$ZV: %SQLGatewayConnection
Comments
建议在Unix上使用JDBCGateway,因为目前只有iODBC支持Unicode
下面是示例代码使用JDBCGateway
#dim%JDBCGatewayAs%Net.Remote.Java.JDBCGatewayset conn = $system.SQLGateway.GetJDBCConnection("TestConn")
if (conn = "") quit0set cmd = "select c1,c2,c3 from wrc943403 where c1 = ?"set st = %JDBCGateway.prepareStatement(conn, cmd)
do%JDBCGateway.setString(st,1,9) // assign c1 to 9set res = %JDBCGateway.execQuery(st)
if (res) {
set error = %JDBCGateway.getErrorText()
write"error = ",error,!
quit
}
while%JDBCGateway.next(st) {
set c1 = %JDBCGateway.getString(st,1)
set c2 = %JDBCGateway.getString(st,2)
write"c1=",c1,!
write"c2=",c2,!
}
write$system.SQLGateway.DropConnection("TestConn")
quit