求Oracle高手帮忙解答

执行if中的语句,就报缺失表达式的错
syqsql := '
insert into tbStat6(Humanid, Ywmc, Ssq, Xgsj)
select '||p_partId||',业务名称,区县名称,
count(发证时间)'||','||'sum(建筑面积)'||','||'count(1)
from (select nvl(b.jzmj, 0) 建筑面积,
c.procid 业务大类标识,
c.subbizid 业务小类标识,
e.bizname 业务名称,
to_char(c.dbsj, ''yyyy/mm/dd'') 登簿时间,
to_char(c.fzsj, ''yyyy/mm/dd'') 发证时间,
c.cantoncode 行政区划,
f.cantonname 区县名称
from cqxx a, fwzk b, tbrec c, tbbiz e, tbcanton f
where a.recid(+) = b.recid
and b.recid = c.recid(+)
and c.subbizid = e.bizid
and c.cantoncode = f.cantoncode
and a.status = 1
and b.status = 1
and c.procid=iBizid
and c.dbsj'||l_startdate||'
and c.dbsj'||l_enddate||')
group by 业务大类标识,
业务小类标识,
业务名称,
区县名称,
行政区划 order by 行政区划';

if iCount = 1 then
execute immediate syqsql;
end if;

是你的insert的字段数小于select的字段数,

把count(发证时间)'||','||'sum(建筑面积)'||','||'count(1)改成

count(发证时间)||‘’,‘'||sum(建筑面积)||’',‘'||count(1)追问

还是不行,还是缺失表达式

追答

p_partId,
l_startdate,
l_enddate 的值是多少

追问

p_partId,
l_startdate,
l_enddate这些都是传进存储过程中的值
p_partId=496,
l_startdate >= to_date('2013-10-11','yyyy-mm-dd'),
l_enddate <= to_date('2013-10-11','yyyy-mm-dd');

追答

l_startdate >= to_date('’2013-10-11‘',’'yyyy-mm-dd'‘),
l_enddate <= to_date('’2013-10-11‘',’'yyyy-mm-dd‘');
试一下

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-20
执行sql出错了。 检查一下sql的语法。。。追问

我把insert语句拿去来执行,是可以执行的。

追答

当执行SQL语句时,不要用分号,当执行PL/SQL块时,在其尾部用分号.
把sql中的分号去掉试试。。。