日期:2014-05-16 浏览次数:20922 次
select intid from a 1 3 5 2 select intid from c 1 4 6 7
create or replace function test_ab(v_intid in varchar2) return varchar2 is out_intid varchar(10); v_sql varchar2(1000); begin dbms_output.put_line('v_intid= '||v_intid); v_sql:='create or replace view ab as select a.intid aa,c.intid bb from a,c where a.intid=c.intid and a.intid='''||v_intid||''''; execute immediate v_sql; select aa+bb into out_intid from ab; dbms_output.put_line('out_intid= '||out_intid); return(out_intid); end test_ab;
select test_ab('1') from dual
create or replace procedure test_ab(v_intid in out varchar2) is v_sql varchar2(1000); begin dbms_output.put_line('v_intid= '||v_intid); v_sql:='create or replace view ab as select a.intid aa,c.intid bb from a,c where a.intid=c.intid and a.intid='''||v_intid||''''; execute immediate v_sql; select aa+bb into v_intid from ab; dbms_output.put_line('v_intid= '||v_intid); end test_ab;
create or replace function test_ab(v_intid in varchar2) return varchar2 is out_intid varchar(10); v_sql varchar2(1000); begin dbms_output.put_line('v_intid= '||v_intid); v_sql:='create or replace view ab as select a.intid aa,c.intid bb from a,c where a.intid=c.intid and a.intid='''||v_intid||''''; execute immediate v_sql; [color=#FF0000]execute immediate 'select aa+bb from ab' into out_intid;[/color] dbms_output.put_line('out_intid= '||out_intid); return(out_intid); end test_ab; declare l_ret varchar2(10); begin l_ret := test_ab('1'); dbms_output.put_line(l_ret); end;
------解决方案--------------------
另外,过程是没有返回值的,如果test_ab是过程,调用方式就是
<