PB修改數據窗口SELECT語句時出錯

fansa 2016-08-10 10:45:46
語句:
if gs_db="" or gs_dh="" then
messagebox("提示","單別單號不能為空")
else
gs_sql="select a.TB001,a.TB002,a.TB026,b.TA070,b.TA053,a.TB009,a.TB028,c.MA002,c.MA121,d.TC012 from EPSTB as a LEFT join EPSTA as b on a.TB001=b.TA001 and a.TB002=b.TA002 Left join COPMA as c on b.TA004=c.MA001 LEFT JOIN COPTC as d on a.TB004=d.TC001 and a.TB005=d.TC002 where a.TB001='"+gs_db+"' and a.TB002='"+gs_dh+"' and b.TA034='Y'"

messagebox("提示" , gs_sql)

dw_1.dataobject='label'
dw_1.setsqlselect(gs_sql)
dw_1.settransobject(sqlca)

// ls_ssss=dw_1.getsqlselect( )

// messagebox("提示" , ls_ssss)
// dw_1.setSQLSelect(gs_sql)

// dw_1.retrieve()

// ls_sql_s='datawindow.table.select="'+gs_sql+' "'
// dw_1.Modify(ls_sql_s)

sle_7.text=gs_sql

if dw_1.retrieve() < 1 then
messagebox("提示" , "未找到任何數據!")
end if
end if

、、、、、、、、、、、、、、、、、、

執行取得的SQL語句
select a.TB001,a.TB002,a.TB026,b.TA070,b.TA053,a.TB009,a.TB028,c.MA002,c.MA121,d.TC012 from EPSTB as a LEFT join EPSTA as b on a.TB001=b.TA001 and a.TB002=b.TA002 Left join COPMA as c on b.TA004=c.MA001 LEFT JOIN COPTC as d on a.TB004=d.TC001 and a.TB005=d.TC002 where a.TB001='B101' and a.TB002='20130601001' and b.TA034='Y'

在SQL平臺執行是沒有問題的,PB執行出錯:datawindow error
select error:attempt to bind to a non-existent column

難道不能用setsqlselect()
...全文
2291 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
baidu_25583473 2016-11-19
  • 打赏
  • 举报
回复
你写的数据列对不上你对应的数据表的列不一样,才会这样的。 你自己去比对一下就可以了。
zhangyangziwo 2016-08-11
  • 打赏
  • 举报
回复
dw自带的sql,跟你更新的sql列数或者对应列的数据类型不匹配 比如,dw里sql可能是8列,但是你给的sql确只有7列, 也可能是,dw里的sql 第N列是数值型,但是你的sql里的第N列确实字符类型 总之,你对比两个sql,就能发现错误
sbks 2016-08-10
  • 打赏
  • 举报
回复
看样子是select出来的数据无法与column做对应 select里为字段加上别名:select a '编码',b '名称'.....
aniu168 2016-08-10
  • 打赏
  • 举报
回复
If the DataWindow is updatable, PowerBuilder validates the SELECT statement against the database and DataWindow column specifications when you call the SetSQLSelect method. Each column in the SQL SELECT statement must match the column type in the DataWindow object. The statement is validated only if the DataWindow object is updatable. You must use the SetTrans or SetTransObject method to set the transaction object before the SetSQLSelect method will execute.

609

社区成员

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

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