首页 新闻 会员 周边 捐助

oracle报错statement ignored,单独执行SQl语句是可以的,Execute immediate nvcSQL就不行了

0
悬赏园豆:5 [待解决问题]


declare
ItemsV nvarchar2(500);
ItemsT nvarchar2(100);
BadItemCount int;
counter number(3):=1;
ItemRn int;
TextItem nvarchar2(100);
ValueItem nvarchar2(100);
nvcCASE nvarchar2(200);
nvcSQL nvarchar2(1000);
begin
select count(*) into BadItemCount from code_items where codeid=(select codeid from code_main where codename='不良行为档次');
while counter<=BadItemCount
loop
select RN,itemtext,itemvalue into ItemRn ,TextItem,ValueItem from (select ROW_NUMBER() OVER(order by orderno asc) as RN , itemtext,itemvalue from code_items where codeid=(select codeid from Code_Main where codename='不良行为档次') order by orderno asc) a where rn=counter;
nvcCASE:='SUM(CASE WHEN B.actiondc= '''||ValueItem||''' THEN 1 ELSE 0 END) as '|| replace(TextItem,' ','')||',';
ItemsV:=ItemsV||nvcCASE;
counter:=counter+1;
end loop;
nvcSQL:='select '||ItemsV||'
A.ItemText,A.ItemValue
from VIEW_CodeMain_CodeItems A
left join View_Xyxx_CorpBadcreditinfo B
on A.ItemValue=B.AuditStatus
where CodeName=''审核状态'' and ItemValue <=4
group by A.ItemValue,A.ItemText
order by ItemValue;';
execute immediate nvcSQL ;
end;

--一下是单独把语句丢出来的执行
select
SUM(CASE WHEN B.actiondc= 'P1' THEN 1 ELSE 0 END) as P1很严重,
SUM(CASE WHEN B.actiondc= 'P2' THEN 1 ELSE 0 END) as P2较严重,
SUM(CASE WHEN B.actiondc= 'P3' THEN 1 ELSE 0 END) as P3严重,
SUM(CASE WHEN B.actiondc= 'P4' THEN 1 ELSE 0 END) as P4中等,
SUM(CASE WHEN B.actiondc= 'P5' THEN 1 ELSE 0 END) as P5一般,
SUM(CASE WHEN B.actiondc= 'P6' THEN 1 ELSE 0 END) as P6轻微,
A.ItemText,A.ItemValue
from VIEW_CodeMain_CodeItems A
left join View_Xyxx_CorpBadcreditinfo B
on A.ItemValue=B.AuditStatus
where CodeName='审核状态' and ItemValue <=4
group by A.ItemValue,A.ItemText
order by ItemValue;

来自潘大大的主页 来自潘大大 | 初学一级 | 园豆:199
提问于:2016-12-05 12:16
< >
分享
所有回答(1)
0

语法问题错误

 

来自潘大大 | 园豆:199 (初学一级) | 2016-12-13 17:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册