PB數(shù)據(jù)窗口使用SetSqlSelect()函數(shù)應(yīng)注意的問題
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.
在腳本中修改數(shù)據(jù)窗口語法時,如果數(shù)據(jù)窗口沒有檢索條件,可以使用Getsqlselect讀取sql語句,修改為自己需要的sql語句后可用Setsqlselect重新設(shè)置查詢條件;也可以用MODIFY()函數(shù)修改,如設(shè)置不同的where條件,另外設(shè)置過后要恢復(fù)原來數(shù)據(jù)窗口的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) //// 數(shù)據(jù)窗口沒有設(shè)置檢索參數(shù)可以用setsqlselect
string ls_tmp
//ls_tmp="DataWindow.Table.Select='"+ls_newsql+"'"http://// 加入的where條件中用到單引號‘’這時dw_1.Modify("DataWindow.Table.Select='select...'")中的單雙引號應(yīng)互換
ls_tmp='DataWindow.Table.Select="'+ls_newsql+'"'
ls_tmp=dw_1.Modify(ls_tmp) ////有檢索參數(shù)就只能用dw_1.modify()
dw_1.setsqlselect(ls_original)
posted on 2010-06-29 16:09
Ke 閱讀(818)
評論(0) 編輯 收藏 所屬分類:
powerBuilder