“ORA-00923:FROM关键字未找到预期位置”仅适用于Oracle 10g而不是11g

时间:2016-04-18 20:21:02

标签: oracle oracle11g ora-00923

我使用的是动态SQL:

https://stackoverflow.com/a/36333897/5021320

根据一天中的时间创建一个表和一些分区。

在Oracle 11g数据库上工作正常,但在Oracle 10g上我收到以下错误:

ORA-00923: FROM keyword not found where expected

尝试运行以下查询alene,也给我错误:

select listagg('PARTITION TABLE_NAME_' || to_char(sysdate + (level-1)/24, 'yyyymmddHH24') ||
' VALUES LESS THAN (TIMESTAMP''' || to_char(sysdate + (level)/24, 'yyyy-mm-dd HH24') || ':00:00''), ')
within group (order by level)
from dual
connect by level <= 24; 

为什么会这样?

1 个答案:

答案 0 :(得分:1)

你可以尝试这样的事情。

   SELECT WMSYS.WM_CONCAT('PARTITION TABLE_NAME_'
  || TO_CHAR(sysdate + (level-1)/24, 'yyyymmddHH24')
  || ' VALUES LESS THAN (TIMESTAMP'''
  || TO_CHAR(sysdate + (level)/24, 'yyyy-mm-dd HH24')
  || ':00:00'') ') OUTPUT
FROM DUAL
  CONNECT BY level <= 24

    -----------------------------OUTPUT----------------------------------------
 OUTPUT
PARTITION TABLE_NAME_2016041907 VALUES LESS THAN (TIMESTAMP'2016-04-19 08:00:00') ,PARTITION TABLE_NAME_2016041908 VALUES LESS THAN (TIMESTAMP'2016-04-19 09:00:00') ,PARTITION TABLE_NAME_2016041909 VALUES LESS THAN (TIMESTAMP'2016-04-19 10:00:00') ,PARTITION TABLE_NAME_2016041910 VALUES LESS THAN (TIMESTAMP'2016-04-19 11:00:00') ,PARTITION TABLE_NAME_2016041911 VALUES LESS THAN (TIMESTAMP'2016-04-19 12:00:00') ,PARTITION TABLE_NAME_2016041912 VALUES LESS THAN (TIMESTAMP'2016-04-19 13:00:00') ,PARTITION TABLE_NAME_2016041913 VALUES LESS THAN (TIMESTAMP'2016-04-19 14:00:00') ,PARTITION TABLE_NAME_2016041914 VALUES LESS THAN (TIMESTAMP'2016-04-19 15:00:00') ,PARTITION TABLE_NAME_2016041915 VALUES LESS THAN (TIMESTAMP'2016-04-19 16:00:00') ,PARTITION TABLE_NAME_2016041916 VALUES LESS THAN (TIMESTAMP'2016-04-19 17:00:00') ,PARTITION TABLE_NAME_2016041917 VALUES LESS THAN (TIMESTAMP'2016-04-19 18:00:00') ,PARTITION TABLE_NAME_2016041918 VALUES LESS THAN (TIMESTAMP'2016-04-19 19:00:00') ,PARTITION TABLE_NAME_2016041919 VALUES LESS THAN (TIMESTAMP'2016-04-19 20:00:00') ,PARTITION TABLE_NAME_2016041920 VALUES LESS THAN (TIMESTAMP'2016-04-19 21:00:00') ,PARTITION TABLE_NAME_2016041921 VALUES LESS THAN (TIMESTAMP'2016-04-19 22:00:00') ,PARTITION TABLE_NAME_2016041922 VALUES LESS THAN (TIMESTAMP'2016-04-19 23:00:00') ,PARTITION TABLE_NAME_2016041923 VALUES LESS THAN (TIMESTAMP'2016-04-20 00:00:00') ,PARTITION TABLE_NAME_2016042000 VALUES LESS THAN (TIMESTAMP'2016-04-20 01:00:00') ,PARTITION TABLE_NAME_2016042001 VALUES LESS THAN (TIMESTAMP'2016-04-20 02:00:00') ,PARTITION TABLE_NAME_2016042002 VALUES LESS THAN (TIMESTAMP'2016-04-20 03:00:00') ,PARTITION TABLE_NAME_2016042003 VALUES LESS THAN (TIMESTAMP'2016-04-20 04:00:00') ,PARTITION TABLE_NAME_2016042004 VALUES LESS THAN (TIMESTAMP'2016-04-20 05:00:00') ,PARTITION TABLE_NAME_2016042005 VALUES LESS THAN (TIMESTAMP'2016-04-20 06:00:00') ,PARTITION TABLE_NAME_2016042006 VALUES LESS THAN (TIMESTAMP'2016-04-20 07:00:00') -----------------------------------------------------------------------------