pb中遍歷查詢資料庫資料問題(資料庫為 sql server)
指標可以實現但是不推薦
例如:(部分程式碼)
for ll_a = 1 to ll_count
ll_b = ll_i + ll_a //插入行行號先下移一位
dw_main.insertrow(ll_b)
select a.part,a.description,a.specification,a.effbegdate,a.effenddate
into :ls_repcomponent,:ls_description,:ls_specification,:ldt_effbegdate,:ldt_effenddate
from
(select bom10110.part,inv11100.description,inv11100.specification,bom10110.effbegdate,bom10110.effenddate,row_number() over (ORDER BY bom10110.part ASC) AS seq //新增臨時序列號
from bom10110,inv11100
where bom10110.part = inv11100.part and
bom10110.parent = :ls_parent and
bom10110.component = :ls_component) a
where a.seq=:ll_a; //讀取每一行資料
sqlca.of_commit()
next
pb中for迴圈的遍歷,要把想要查詢的資料顯示出來. 先給查詢出的資料設定一個臨時序列號. 通過序列號迴圈遍歷每一行資料,相當於與一個指標的效果
sql server中:
//方法一 (oracle貌似也可以沒試驗 以後待驗證)
SELECT ROW_NUMBER() over(order by 列名) as 序列號名稱
列名,列名......
FROM客戶;
//方法二
SELECT RANK() OVER (ORDER BY 列名 DESC) AS 序號,
列名,列名......
FROM客戶;
mysql中 :
select (@i:[email protected]+1) as i,table_name.* from table_name,(select @i:=0) as it
後面可加order 排序