已创建存储过程但未返回输出

时间:2015-06-04 09:44:21

标签: oracle oracle11g toad

我创建了一个存储过程 - 它在服务器上成功创建但是当我执行它时,我收到Procedure Completed消息,但它没有返回任何输出。

程序如下

CREATE OR REPLACE PROCEDURE DFADMIN.USP_GETPICKLIST_DF
(
 P_ORD_TYPE IN varchar2,
 P_PICKLIST_OUT OUT SYS_REFCURSOR,
 P_PICKLIST_ORD OUT SYS_REFCURSOR
)
AS
 v_TotalOpenOrder integer;
 v_AstockQty integer;
 v_BstockQty integer;
 v_loopCounter integer;
 v_Astock integer;
 v_Bstock integer;
 v_TotalBStockQty integer;

 BEGIN
    SELECT COUNT(DISTINCT ORD_NBR) INTO v_TotalOpenOrder  FROM DFADMIN.DF_ORDERS WHERE ORD_STATUS='OPEN' AND ORD_TYPE='DF';
 begin
        if v_TotalOpenOrder>0 then
            v_BstockQty:=round(((v_TotalOpenOrder*60)/100),0);
            v_AstockQty:=v_TotalOpenOrder-v_BstockQty;
             select count(1) into v_Astock  from DFADMIN.Ro_HIST where Process='ASTOCK' AND ORDER_TYPE='DF';
            select count(1) into v_Bstock  from DFADMIN.Ro_HIST where Process='BSTOCK' AND ORDER_TYPE='DF';

            if (v_Bstock < v_BstockQty) then
                open P_PICKLIST_OUT for
                    select T.QTY,T.PUTAWAY_BIN BIN,T.BOXID BOX_ID ,T.PICKQTY PICK_QTY from
                    (
                        Select  sum(I.QTY) QTY, I.PUTAWAY_BIN,I.BOXID,'1' as PickQty
                        from  (select * from DFADMIN.Ro_HIST where ORDER_TYPE='DF' and QTY<=v_Bstock order by created_date asc ) I
                        Where  BOXID in (select K.BOXID from DFADMIN.RO_HIST K)
                        and  I.PROCESS='BSTOCK'  and  I.PUTAWAY_BIN is not null   and QTY<=v_Bstock
                        group by I.PUTAWAY_BIN,I.BOXID,I.QTY, I.PROCESS,'1'
                    union
                        Select  sum(I.QTY) QTY, I.PUTAWAY_BIN,I.BOXID,'1' as PICKQTY
                        from  (select * from DFADMIN.Ro_HIST where  ORDER_TYPE='DF' order by CREATED_DATE asc ) I
                        Where  BOXID in (select K.BOXID from DFADMIN.RO_HIST K )
                        and  I.PROCESS='ASTOCK'  and  I.PUTAWAY_BIN is not null  and QTY<=(v_TotalOpenOrder-v_Bstock) --and case when v_Bstock>0 then  rownum<=(v_TotalOpenOrder-v_Bstock) else rownum>0 end
                        group by I.PUTAWAY_BIN,I.BOXID,I.QTY, I.PROCESS,'1'
                    ) t  order by  T.QTY asc;
                    open P_PICKLIST_ORD for
                    select distinct ORD_NBR,'' QTY,''  BIN,'' BOX_ID ,'' PICK_QTY from  DFADMIN.DF_ORDERS where ORD_STATUS='OPEN' AND ORD_TYPE='DF' ;
                    ELSE 
                    begin
                              open P_PICKLIST_OUT for
                    select T.QTY,T.PUTAWAY_BIN BIN,T.BOXID BOX_ID ,T.PICKQTY PICK_QTY from
                    (
                        Select  sum(I.QTY) QTY, I.PUTAWAY_BIN,I.BOXID,'1' as PickQty
                        from  (select * from DFADMIN.Ro_HIST where ORDER_TYPE='DF' AND QTY<=v_Bstock order by created_date asc ) I
                        Where  BOXID in (select K.BOXID from DFADMIN.RO_HIST K )
                        and  I.PROCESS='BSTOCK'  and  I.PUTAWAY_BIN is not null   and QTY<=v_BstockQty
                        group by I.PUTAWAY_BIN,I.BOXID,I.QTY, I.PROCESS,'1'
                    union
                        Select  sum(I.QTY) QTY, I.PUTAWAY_BIN,I.BOXID,'1' as PICKQTY
                        from  (select * from DFADMIN.Ro_HIST WHERE ORDER_TYPE='DF' order by CREATED_DATE asc ) I
                        Where  BOXID in (select K.BOXID from DFADMIN.RO_HIST K )
                        and  I.PROCESS='ASTOCK'  and  I.PUTAWAY_BIN is not null  and QTY<=(v_TotalOpenOrder-v_BstockQty) --and case when v_Bstock>0 then  rownum<=(v_TotalOpenOrder-v_Bstock) else rownum>0 end
                        group by I.PUTAWAY_BIN,I.BOXID,I.QTY, I.PROCESS,'1'
                    ) t  order by  T.QTY asc;
                    open P_PICKLIST_ORD for
                    select distinct ORD_NBR,'' QTY,''  BIN,'' BOX_ID ,'' PICK_QTY from  DFADMIN.DF_ORDERS where ORD_STATUS='OPEN' AND ORD_TYPE='DF';
                    end ;

            end if;

        end if;

   end;

 END USP_GETPICKLIST_DF;

在此过程中,有一个输入参数和2个输出参数。

1 个答案:

答案 0 :(得分:0)

在您的程序中,没有dbms_output或类似的东西,这会导致输出/显示任何数据。

有两个输出参数是sys_refcursor类型,所以我想 在执行过程后,您正在考虑将这些参数作为所需的输出内容。在调用该过程之后,您可以将这些游标提取到变量中,然后例如显示这样的数据。

declare
vpicklist_out sys_refcursor;
vpicklist_ord sys_refcursor;
myRecord mytable%ROWTYPE;
begin
USP_GETPICKLIST_DF('somestring', vpicklist_out ,vpicklist_ord );
 LOOP
      FETCH vpicklist_out INTO myRecord1;
        EXIT WHEN vpicklist_out%NOTFOUND;
       dbms_output.put_line(to_char(myRecord1.col1));
  END LOOP;
end;

请注意,我不知道您数据的确切结构,因此myRecord在我的示例中声明为某个名为mytable的表的ROWTYPE