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:=@i+1)   as   i,table_name.*   from   table_name,(select   @i:=0)   as   it 

    后面可加order 排序

猜你喜欢

转载自www.cnblogs.com/shiwei666/p/9961958.html