plsql 저장 프로세스, 페이지 조회

1454 단어
학습 기록
  procedure PQ_PS_OrderList
  (
   I_PageSize       In Number, --     
   I_PageNO         In Number, --    
   O_OutRecordCount Out Number, --    
   O_OutCursor      Out t_cursor, --    
   O_Result         Out Number,
   O_Message        Out Varchar2 
  )
  is
  v_sql       Varchar2(2000) := '';
  v_HeiRownum Number;
  v_LowRownum Number;

  begin
    O_Result  := 0;
    O_Message := '    ';
  
   v_sql:='select ACCOUNT_ID,USER_ID,DEVICE_ID from 
           USER_DRAW_ALIPAY where STATUS=0';
   --    
   execute immediate 'select count(1) from ('||v_sql||')' into O_OutRecordCount;
   	
   --      
   v_HeiRownum:=I_PageNO * I_PageSize;
   v_LowRownum:=v_HeiRownum - I_PageSize+1;
   v_sql:='select ACCOUNT_ID,USER_ID,DEVICE_ID,rn
                  from(
                  select ACCOUNT_ID,USER_ID,DEVICE_ID,rownum rn 
                  from('||v_sql||') A 
                  where rownum<='||
                  to_char(v_HeiRownum) ||'
                  ) B
                  where rn >='|| to_char(v_LowRownum);             
   open O_OutCursor for v_sql;
   
   commit;
   return;
                             
    exception
    when others then
      rollback;
      O_Result  := -9;
      O_Message := '         :' || sqlcode || '       :' || sqlerrm;
      return;

  end PQ_PS_OrderList;

  
end P_USER_DRAW_ALIPAY;

좋은 웹페이지 즐겨찾기