当前位置: 代码迷 >> PB >> 数据窗口列名无效,怎么继续检索出其他列的数据以显示在数据窗口中
  详细解决方案

数据窗口列名无效,怎么继续检索出其他列的数据以显示在数据窗口中

热度:14   发布时间:2016-04-29 10:12:44.0
数据窗口列名无效,如何继续检索出其他列的数据以显示在数据窗口中
现有一数据窗口,其有一列名在数据库中不存在,但仍想检出其他列的数据,其不存在的列以缺省值显示,已在error事件中设置了返回值,但无效

------解决方案--------------------
在dberror事件中,这么写试试,当然你可以按照这种思路自己进行改进
C/C++ code
if pos(sqlerrtext, 'Select error: 列名') > 0 then    string ls    ls = mid(sqlerrtext, pos(sqlerrtext, "'") + 1, pos(sqlerrtext, "'", pos(sqlerrtext, "'") + 1) - pos(sqlerrtext, "'") - 1)    ls = left(sqlsyntax, pos(sqlsyntax, ls) - 1) + "'默认值' as " + ls + mid(sqlsyntax, pos(sqlsyntax, ls) + len(ls))    setsqlselect( ls)    post retrieve()end ifreturn 1
------解决方案--------------------
改一下SQL 语法,把不显示的那一列 设为虚拟列 '' as column_name即可
------解决方案--------------------
SQL code
select xmbh, case when col_length('tb', 'zcbb') is null then ''   else zcbh end as zcbh,kmbh  from tb
------解决方案--------------------
设为虚列同时不能在sql中引用不存在的列,否则执行时还是会报错的。
  相关解决方案