create or replace procedure BILLDATE_PROC
(
strdate VARCHAR2,
strenddate VARCHAR2,
strBiz VARCHAR2
)
AS
BEGIN
EXECUTE IMMEDIATE 'create table TESTONESTR as(select ''20080401-20080417'' 日期,
(select propertyvalue from machineinfo where propertycode=''20'' and
macid=PAYMENTINFO.MACID) 营业厅, (select machinecode from machineindex
where macid=PAYMENTINFO.MACID) 设备编号,(select selectitemname from
dropdownlist where ddlname=''缴费状态'' and selectitemvalue=PAYSTATE)
缴费状态,count(PAYMONEY) 交易笔数, sum(PAYMONEY) 交易金额 from PAYMENTINFO
where (PAYMENTINFO.PAYDATETIME between to_date('||strdate||',''yyyymmdd'') and
to_date('||strenddate||',''yyyymmdd'')) and PAYMENTINFO.MACID in (select macid from
machineinfo where PropertyCode=''20'' and propertyvalue='||strBiz||')
group by PAYMENTINFO.MACID,PAYMENTINFO.PAYSTATE) order by 营业厅,设备编号,缴费状态';
END;
这是我写的存储过程,我写execute BILLDATE_PROC('20080415','20080415','芙蓉区营业厅'); 调用
但是报错
ERROR 位于第 1 行:
ORA-00904: 无效列名
ORA-06512: 在"USERNAME.BILLDATE_PROC", line 9
ORA-06512: 在line 1
有哪位高手知道啥原因不,我把SQL语句独立出来是可以运行的。。
------解决方法--------------------------------------------------------
可能是中文的问题,试试E文。
------解决方法--------------------------------------------------------
要在SQL\Plus里面运行execute BILLDATE_PROC('20080415','20080415','芙蓉区营业厅');
或者在PL\SQL的Command模式运行execute BILLDATE_PROC('20080415','20080415','芙蓉区营业厅');
------解决方法--------------------------------------------------------
是你的动态sql写的有问题,应该是某个字段名不存在或写错了,按如下方式调试:
先按这样修改过程:
create or replace procedure BILLDATE_PROC
(
strdate VARCHAR2,
strenddate VARCHAR2,
strBiz VARCHAR2
)
AS
var_sql varchar2(8000);
BEGIN
var_sql := 'create table TESTONESTR as(select ''20080401-20080417'' 日期,
(select propertyvalue from machineinfo where propertycode=''20'' and
macid=PAYMENTINFO.MACID) 营业厅, (select machinecode from machineindex
where macid=PAYMENTINFO.MACID) 设备编号,(select selectitemname from
dropdownlist where ddlname=''缴费状态'' and selectitemvalue=PAYSTATE)
缴费状态,count(PAYMONEY) 交易笔数, sum(PAYMONEY) 交易金额 from PAYMENTINFO