ORA-01861: literal does not match format string 错误!

SQL> CREATE OR REPLACE  PROCEDURE "SGREPORTS"."METRIC_DATA_ROLLUP" (rollup_time DATE)
  2  AS
  3     default_time   DATE := rollup_time;
  4  BEGIN
  5     begin
  6     EXECUTE IMMEDIATE ('ALTER SESSION SET TIME_ZONE = DBTIMEZONE');
  7      execute immediate ('alter session set nls_date_format=''YYYY-MM-DD HH24:MI:SS''');
  8      execute immediate ('alter session set nls_language=american');
  9     IF rollup_time IS NULL
 10     THEN
 11        default_time := TRUNC (SYSDATE, 'HH24') - 1 / 24;
 12     ELSE
 13        default_time := TRUNC (default_time, 'HH24');
 14     END IF;
 15    DELETE FROM metric_data_hourly
 16           WHERE datetime = cast(TO_TIMESTAMP_TZ(default_time, 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP WITH LO
 17    EXCEPTION
 18     WHEN OTHERS
 19     THEN
 20        dbms_output.put_line('syntax error:'||SQLerrm);
 21    end;
 22    begin
 23     INSERT INTO metric_data_hourly SELECT  /*+INDEX(A1,PK_METRIC_DATA_HOURLY)*/ *
 24            FROM sgreports.metric_data_hourly@RPTS.NILE002A_ZONE01.EAST A1
 25           WHERE datetime between cast(TO_TIMESTAMP_TZ(default_time, 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP W
 26       and  cast(TO_TIMESTAMP_TZ(default_time, 'YYYY-MM-DD HH24:MI:SS')+ 3599 / 86400 AS TIMESTAMP WITH LOCA
 27     EXCEPTION
 28        WHEN OTHERS
 29        THEN
 30           dbms_output.put_line(SQLerrm);
 31     END;
 32  end;
 33  /

过程已创建。

SQL>  exec metric_data_rollup ('2009-04-11 21:00:00');
BEGIN metric_data_rollup ('2009-04-11 21:00:00'); END;

*
第 1 行出现错误:
ORA-01861: literal does not match format string
ORA-06512: at line 1


SQL> alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';

会话已更改。

SQL> alter session set nls_language=american;

Session altered.

SQL>  exec metric_data_rollup ('2009-04-11 21:00:00');

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值