过程:
CREATE OR REPLACE PROCEDURE P_TEST IS
V_SQL VARCHAR2(2000);
selected VARCHAR2(2000);
qxmcCount integer;
CURSOR CURSOR_1 IS SELECT DISTINCT qxmc FROM xt_instance where qxmc is not null;
BEGIN
qxmcCount := 1;
V_SQL :='select tbase.name $selected$ from (select distinct name from(
select r.name from xt_instance x,sys_receive_djlx r where x.djlx_code=r.code
order by x.djlx_code)) tbase ';
FOR V_XCLCK IN CURSOR_1
LOOP
V_SQL := V_SQL || ' full outer join ';
V_SQL := V_SQL || ' (select
name,
sum(decode(qxmc, '''|| V_XCLCK.qxmc ||''', c)) '|| V_XCLCK.qxmc ||'
from
(select x.qxmc,count(1) c,r.name from xt_instance x,sys_receive_djlx r where x.djlx_code=r.code
and x.qxmc='''|| V_XCLCK.qxmc ||'''
group by x.qxmc,r.name
)
group by name) t'||qxmcCount||' on t'||qxmcCount||'.name=tbase.name ';
selected := selected || ',t'||qxmcCount||'.'|| V_XCLCK.qxmc;
qxmcCount := qxmcCount + 1;
END LOOP;
V_SQL := replace(V_SQL,'$selected$',selected);
dbms_output.put_line(V_SQL);
--EXECUTE IMMEDIATE V_SQL;
END;
beg
P_TEST();
end
错误提示:
ORA_O6550:第4行,第0列:
PLS_00103出现符号“end-of-file”在需要下列之一时:;<an identifile> <a double quoted delimited-identifile>符号";"被替换为"end-of-file"后继续
------解决思路----------------------
begin
P_TEST();
end
和创建语句,你要分开执行,或者在 sql command 窗口中执行。