create or replace procedure p_GetList_AnyTable_s 

in_select varchar2, /*select 后面传入sql语句*/ 
in_from varchar2, /*from 后面传入sql语句*/ 
in_where varchar2, /*where 后面传入sql语句*/ 
in_order_by varchar2, /*order by 后面传入sql语句*/ 
in_currentpage number /*当前页*/ 
/*out_maxbtotalpage out number*/ /*可显示最大页书*/ 

is 
str varchar2(1000); 
pagetotal number:=10; /*每页显示记录数*/ 
mina number; 
maxb number; 
begin 
mina:=in_currentpage+(pagetotal*(in_currentpage-1)); 
maxb:=in_currentpage*pagetotal; 
str:='select '||in_select||' from (select '||in_select||',rownum rn from '||in_from||' where ';if(in_where is not null)then 
str:=str||in_where||' and '; 
end if; 
str:=str||'rownum<='||maxb||') where rn>='||mina; 
if(in_order_by is not null)then 
str:=str||' order by '||in_order_by; 
end if; 
execute immediate str;
end;
/

解决方案 »

  1.   

    如果我有表AAA(aa number,bb varchar2(500))
    如何调用存储过程来显示AAA中的数据
      

  2.   

    procedure p_GetList_AnyTable_s(aa,AAA,参数,参数,参数)
      

  3.   

    我用以下语句不行呀!
    begin
    exec  p_GetList_AnyTable_s(aa,AAA,where aa=1,aa,1);
    end;提示:
    ERROR 位于第 2 行:
    ORA-06550: 第 2 行, 第 7 列:
    PLS-00103: 出现符号 "P_GETLIST_ANYTABLE_S"在需要下列之一时:
    := . ( @ %
    ;
    符号 ":=" 被替换为 "P_GETLIST_ANYTABLE_S" 后继续。
    ORA-06550: 第 2 行, 第 35 列:
    PLS-00103: 出现符号 "WHERE"在需要下列之一时:
    ( - + case mod new not
    null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute
      

  4.   

    我用以下语句出不行为什么??
    begin
    str varchar2(1000); 
    str:='select * from AAA ';
    execute immediate str;
    end