要定义游标类型 type g_rs is ref curosr;
CREATE OR REPLACE procedure ZXM_SB_GZ_GET
(p_table in varchar2,
p_name in varchar2,
p_value in varchar2,
rs out g_rs
)
as
wherevalue varchar2(200);
begin
wherevalue:='select * from '||p_table||' where '||p_name||'='||p_value;
open rs for wherevalue; end;
CREATE OR REPLACE procedure ZXM_SB_GZ_GET
(p_table in varchar2,
p_name in varchar2,
p_value in varchar2,
rs out g_rs
)
as
wherevalue varchar2(200);
begin
wherevalue:='select * from '||p_table||' where '||p_name||'='||p_value;
open rs for wherevalue; end;
在包体中就可以使用了,单在存储过程中使用,我没有试过
另外我copy了你的代码编译后还是又错误啊
行号= 0 列号= 0 错误文本= PL/SQL: Compilation unit analysis terminated
行号= 5 列号= 10 错误文本= PLS-00201: 必须说明标识符 'G_RS'
create or replace function f_sczhdt_kz(as_sql in varchar2,as_table in varchar2) return Number is
/*
传过来begindate日期来作为过滤条件)
传过来enddate日期来作为过滤条件)
交付数
*/
v_sql varchar2(2000);
v_sum number(8);
begin
if as_table='c_well' then
v_sql :='select count(1) from '||as_table||' where 1=1 ';
else
v_sql :='select count(1) from '||as_table||',c_well where 1=1 and c_well.wellno='||as_table||'.wellno ';
end if;
if as_sql is not null then
v_sql := v_sql||as_sql;
end if;
execute immediate v_sql into v_sum;
return v_sum;
end f_sczhdt_kz;