oracle 存储过程 报 无效字符

来源:互联网 发布:flickerplate.js 编辑:程序博客网 时间:2024/06/06 12:39
create or replace procedure insert_MQdetail_table is  -------------------指定数据生成只需修改以下条件-----------------------------  --定义数据生成时间范围  /*start_date varchar2(100):='20150501';  end_date varchar2(100):='20150603';*/  --查询需要生成数据的指标记录 in ('GW0073','GW0074','GW0022','GW0075','GW0036','GW0040')  cursor gdata_dict is(select t.id,t.today_sql from zyhipsys.monitor_quota_info t);  -----------------------------------------------------------------------------  --变量声明  vsql varchar2(2000);--sql语句  vsid varchar2(200);--info id  vsCoutn varchar2(4000);--最新的数目  vsCoutnTemp varchar2(4000);--临时的数目  vaNewDetailId varchar2(200);--要插入的新的主键begin  --循环指标配置表记录  for vvv in gdata_dict loop      begin        vsql:=vvv.today_sql;        vsid:=vvv.id;        begin           execute immediate vsql into vsCoutn;--根据配好的sql语句查询当日的数目        end;        if vsql is not null then            execute immediate 'select count(*) from zyhipsys.monitor_quota_detail t where  t.insert_time >= trunc(sysdate)            and t.insert_time < trunc(sysdate + 1) and t.info_id=:1' into vsCoutnTemp using vsid;        end if;        if vsCoutnTemp=0 then          --执行插入            execute immediate 'select monitor_quota_detail_seq.nextval from dual' into vaNewDetailId;            execute immediate 'insert into zyhipsys.monitor_quota_detail t (t.id,t.info_id,t.quota_value,t.insert_time,t.valid_flag)                               values(:1,:2,:3,sysdate,1)' using  vaNewDetailId,vsid,vsCoutn;        else          --执行更新            execute immediate 'update zyhipsys.monitor_quota_detail t set t.quota_value=:1  where  t.insert_time >= trunc(sysdate)            and t.insert_time < trunc(sysdate + 1)  and t.info_id=:2 ' using  vsCoutn,vsid;        end if;      end;      end loop;end insert_MQdetail_table;


原因是因为 在execute immediate vsql into vsCoutn  这边根据语句查询的时候得到数目的时候 加了 ;

;号和/都是执行的含义,如果使用了/就不需要使用分号了。
如果是执行存储过程则必须使用/

0 0