当我从后端运行此查询时,出现错误

问题描述 投票:-1回答:1
SQL> select
  2  DECODE (TNOT_NOTICE_TYPE,
  3      '1200', 'Duration Challenge ',
  4      '1400', 'Informal Overrun Warning ',
  5      '1500', 'Works Comments ',
  6      '1600', 'Direction on Timing ',
  7      '1601', 'Direction on Placing Apparatus ',
  8      '1602', 'Undue Delay ',
  9      '1611', 'Grant Permit ',
 10      '1613', 'Refuse Permit ',
 11      '2100', 'FPN Notice ',
 12      '2101', 'FPN Withdrawal ',
 13      '2200', 'FPN Comments ',
 14      '2600', 'Inspection ',
 15      '2800', 'Temporary Traffic Signal Application Responses '
 16      ) || 'Received' AS "Subject",
 17  DECODE (TNOT_NOTICE_TYPE,
 18      '1200', 'Duration Challenge - ',
 19      '1400', 'Informal Overrun Warning - ',
 20      '1500', 'Works Comments - ',
 21      '1600', 'Direction on Timing - ',
 22      '1601', 'Direction on Placing Apparatus - ',
 23      '1602', 'Undue Delay - ',
 24      '1611', 'Grant Permit - ',
 25      '1613', 'Refuse Permit - ',
 26      '2100', 'FPN Notice - ',
 27      '2101', 'FPN Withdrawal - ',
 28      '2200', 'FPN Comments - ',
 29      '2600', 'Inspection - ',
 30      '2800', 'Temporary Traffic Signal Application Responses - '
 31      ) || SUBSTR(TNOT_WORKS_REF, 3, 3) AS "Alert Description",
 32  SUBSTR(TNOT_WORKS_REF, 3, 3) AS "District"    ,
 33  TNOT_SENDER_ORG_REF as "Org Ref",
 34  TNOT_SENDER_DIST_REF as "Dist Ref",
 35  TNOT_DATE_MODIFIED as "Date Modified",
 36  TNOT_DATE_MODIFIED as "Date Modified",
 37  TNOT_WORKS_REF as "Works Ref",
 38  TNOT_COMMENTS as "Comments",
 39  TNOT_WORKS_DESCRIPTION AS "Works Description",
 40  TNOT_LOC_DESCRIPTION AS "Location Description",
 41  TNOT_NOTICE_TYPE ,
 42  TNOT_CREATED_DATIM
 43  from TMA_NOTICES
 44  where
 45  TNOT_SENT_RECEIVED = 'R'
 46  AND TNOT_WORKS_REF LIKE 'AY009%'
 47  AND TNOT_NOTICE_TYPE IN ('1200','1400', '1500', '1600', '1601', '1602', '16
11', '1613', '2100', '2101', '2200','2600', '2800')
 48  AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
 49  ORDER BY TNOT_NOTICE_TYPE, TNOT_CREATED_DATIM DESC;
AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
                               *

****第48行的错误:

ORA-01830:日期格式图片在转换整个输入之前结束字符串****

SQL>

sql oracle unix backend
1个回答
0
投票

要将字符串转换为日期,您需要使用TO_DATE函数或DATE文字,如下所示:

Replace '01-OCT-19 00:00:00' with -> DATE '2019-10-01'
-- OR --
Replace '01-OCT-19 00:00:00' with -> TO_DATE('01-OCT-19 00:00:00','DD-MON-RR HH24:MI:SS')

干杯!

© www.soinside.com 2019 - 2024. All rights reserved.