热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

Oracle动态SQL注意细节ORA-00911:无效字符

groupbytrunc(INSERTTIME),TO_CHAR(INSERTTIME,

group by trunc(INSERTTIME),TO_CHAR(INSERTTIME,

lv_sql:='
insert into ETL_SUCESS_AMOUNT
select SEQ_OS_ETL_AMOUNTID.NEXTVAL AS AMOUNTID,1,AMOUNT_DATA,AMOUNT_HOUR,
serviceid,portalid,mouduleid,actionid,RESERVE1_ID,RESERVE2_ID,RESERVE3_ID,
RESERVE4_ID,AMOUNT,AMOUNT_TIME
from
(
select
trunc(INSERTTIME) AS AMOUNT_DATA,
TO_CHAR(INSERTTIME,''HH24'') AS AMOUNT_HOUR,
serviceid,portalid,mouduleid,actionid,
NULL AS RESERVE1_ID,
NULL AS RESERVE2_ID,
NULL AS RESERVE3_ID,
NULL AS RESERVE4_ID,
count(*) AS AMOUNT,
SYSDATE AS AMOUNT_TIME
from '||lv_table_name||'
where inserttime > to_date(:1,''yyyy-mm-dd hh24:mi:ss'')
and inserttime group by trunc(INSERTTIME),TO_CHAR(INSERTTIME,''HH24''),serviceid,mouduleid,portalid,actionid
)';
execute immediate lv_sql USING p_sdate,p_edate;

-- 细节动态语句里面不需要分号

--细节(''HH24'') 动态语句里面单引号要双写

--细节 from '||lv_table_name||' 语句之间注意空格符号

--细节使用参数:1 USING p_sdate,p_edate;

linux


推荐阅读
author-avatar
dazhi20
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有