可以实现,用游标:
cursor c is select .......
begin 
    open c;
    loop
        fetch c into ...;
        exit when c%notfound;
       ....
    end loop;
    close c;
    .....
end;

解决方案 »

  1.   

    最近正好用到如下,希望有所帮助:
    CREATE TRIGGER TRIG_OPERATION
    AFTER INSERT ON AUTHOPERATION FOR EACH ROW
    DECLARE
        --定义变量
        OperationId  varchar2(15) := :new.OperationId;
        aAppTypeId   varchar2(15) := :new.AppTypeId;
        tFlowId      varchar2(15);
        --定义游标
        CURSOR cur_operation
        is
        select FlowId
            from authflow
                where authflow.flowtemplateid =
                    (
                        select apptype.flowtemplateid
                            from apptype
                                where apptype.apptypeid = aAppTypeId
                    )
                    order by flowid asc;
    BEGIN
        --打开游标
        open cur_operation;
        --取出数据
        fetch cur_operation into tFlowId;
        --循环
        while cur_operation%found
        loop
            INSERT INTO AUTHAUTHORIZE VALUES('',OperationId,tFlowId,'','','','','','','','','-1');
            fetch cur_operation into tFlowId;
        end loop;
        --关闭游标
        close cur_operation;
    END;
    /
    实现功能是取得flowid,然后将flowid和其他的一些值循环插入到AUTHAUTHORIZE表里面来(循环次数为取得flowid的个数).