从pl sql过程的输出创建视图

时间:2017-06-14 08:06:11

标签: oracle plsql views procedure

我有一个pl sql程序,它返回订单及其状态。我只需要卡住订单,所以我在pl sql存储过程中编写了一些逻辑。现在,我想从这个pl sql过程的输出创建一个视图。这可能吗?如果是,那怎么样?这是程序代码示例。

create or replace procedure stuck_order 
is
  id    table_order.id%type;
  state table_status.state%type;
  count number(8,2);
  cursor cur1 is (select id 
                    from table_order);
  cursor cur2 is (select state 
                    from table_status);
begin
  open cur1
  loop 
    fetch cur1 into id;
    exit when cur1%notfound;
    count := 0;
    open cur2;
    loop
      fetch cur2 into state;
      exit when cur2%notfound;
      if(state = 1)
      then
        count := count + 1;
      end if;
    end loop
    close cur2;
    if(count = 0)
      dbms_output.Put.line(id || 'stuck')
    end if;
  end loop;
  close cur1;
end;

0 个答案:

没有答案