请教,数据窗口 SetSQLSelect 中where in依据数组的问题。

guangmingshui 2020-12-15 09:16:47
pb12.6环境,需要依据数组内容动态更改数据窗口。
代码:
old_select=dw_1.GetSQLSelect ( )
string shuzu[500]
数组shuzu赋值 略
new_select=old_select+ ' where pid in (:shuzu) '
dw_1.SetSQLSelect(new_select)
dw_1.settrans(sqlca)
dw_1.retrieve(shuzu)

错误信息为:
Select Error:SQLSTATE = 37000
[Microsoft][ODBC SQL Server Driver][SQL Server]':'附近有语法错误。
...全文
682 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
如果你使用DW入参形式retrieve的话,是支持数组的
  • 打赏
  • 举报
回复
不支持动态SQL使用数组;你上面的代码必须把数组中的值拼接成字符串,然后和sql拼接一起

string ls_test

//ls_test的值=拼接数组中的值

ls_test = "'123213','12312321','3123213213'"

new_select=old_select+ ' where pid in ('+ls_test+') '
dw_1.SetSQLSelect(new_select)
dw_1.settrans(sqlca)
dw_1.retrieve(shuzu)

611

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧