PB数据窗口使用SetSqlSelect()函数应注意的问题
Limitations to using SetSQLSelectUse SetSQLSelect only if the data source for the DataWindow object is a SQL SELECT statement without retrieval arguments and you want PowerBuilder to modify the update information for the DataWindow object:
dw_1.Modify("DataWindow.Table.Select='select...'")
Modify will not verify the SELECT statement or change the update information, making it faster but more susceptible to user error. Although you can use Modify when arguments are involved, it is not recommended because of the lack of checking.
在脚本中修改数据窗口语法时,如果數據窗口沒有檢索條件,可以使用Getsqlselect读取sql语句,修改为自己需要的sql语句后可用Setsqlselect重新设置查询条件;也可以用MODIFY()函数修改,如设置不同的where条件,另外设置过后要恢复原来数据窗口的sql语句。
如果有检索条件就不能用setsqlselect,
只可以用dw_1.Modify("DataWindow.Table.Select='select...'")
Eg:
ls_original=dw_1.getsqlselect()
if rb_3.checked=true then //base salary
ls_newsql=ls_original +" and (staff_master.monthly_pay=0 )"
else // fixed salary
ls_newsql=ls_original +" and (staff_master.monthly_pay in ('1','2','3') )"
end if
//int i
//i=dw_1.setsqlselect(ls_newsql) //// 数据窗口没有设置检索参数可以用setsqlselect
string ls_tmp
//ls_tmp="DataWindow.Table.Select='"+ls_newsql+"'"//// 加入的where条件中用到单引号‘’这时dw_1.Modify("DataWindow.Table.Select='select...'")中的单双引号应互换
ls_tmp='DataWindow.Table.Select="'+ls_newsql+'"'
ls_tmp=dw_1.Modify(ls_tmp) ////有检索参数就只能用dw_1.modify()
dw_1.setsqlselect(ls_original)
posted on 2010-06-29 16:09
Ke 阅读(810)
评论(0) 编辑 收藏 所属分类:
powerBuilder