PB數(shù)據(jù)窗口使用SetSqlSelect()函數(shù)應(yīng)注意的問(wèn)題
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ù)窗口語(yǔ)法時(shí),如果數(shù)據(jù)窗口沒(méi)有檢索條件,可以使用Getsqlselect讀取sql語(yǔ)句,修改為自己需要的sql語(yǔ)句后可用Setsqlselect重新設(shè)置查詢(xún)條件;也可以用MODIFY()函數(shù)修改,如設(shè)置不同的where條件,另外設(shè)置過(guò)后要恢復(fù)原來(lái)數(shù)據(jù)窗口的sql語(yǔ)句。
如果有檢索條件就不能用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ù)窗口沒(méi)有設(shè)置檢索參數(shù)可以用setsqlselect
string ls_tmp
//ls_tmp="DataWindow.Table.Select='"+ls_newsql+"'"http://// 加入的where條件中用到單引號(hào)‘’這時(shí)dw_1.Modify("DataWindow.Table.Select='select...'")中的單雙引號(hào)應(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 閱讀(817)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
powerBuilder