Oracle 10g中的编码错误

时间:2017-11-03 09:04:00

标签: oracle

这是我所知道的巨大代码。但如果有人能帮忙,我会很高兴;)  .Problem是执行此代码时出现此错误(在照片中)。我现在尝试了一段时间,但无法修复此错误,因为我是Oracle的新手。

Problem is when execute this code this error showing(in photo)

Declare v_StartDateTime TIMESTAMP(3):='2017-01-01 00:00:00'
v_EndDateTime TIMESTAMP(3):='2017-12-31 23:59:59'
;WITH CTE
AS
(
SELECT 
v_StartDateTime AS DateSlotStart 
,INTERVAL '-1' SECOND  + INTERVAL '1' hh +v_StartDateTime AS DateSlotEnd, 
 CAST(v_StartDateTime as DATE) AS Date
,TO_CHAR(CAST(v_StartDateTime AS TIMESTAMP) ,113)||' To '||  
 TO_CHAR(CAST(INTERVAL '-1' SECOND  + INTERVAL '1' hh +v_StartDateTime  AS 
 TIMESTAMP) ,113)  SlotName
 UNION ALL

 SELECT INTERVAL '1' hh +DateSlotStart AS [DateSlotStart] ,INTERVAL '-1' 
 SECOND  +  INTERVAL '2' hh +DateSlotStart AS [DateSlotEnd]
 , CAST(INTERVAL '1' hh +DateSlotStart AS DATE) AS [Date]  
 ,TO_CHAR(CAST(INTERVAL '1' hh +DateSlotStart AS TIMESTAMP) ,113) ||' To '|| 
  TO_CHAR(CAST(INTERVAL '-1' SECOND  +  INTERVAL '2' hh +DateSlotStart  AS 
  TIMESTAMP) ,113)  SlotName
  FROM CTE 
  WHERE CAST(INTERVAL '1' hh +DateSlotStart AS DATE) < v_EndDateTime
  )


 INSERT INTO DimDate
       (DateSlotStart
       ,DateSlotEnd
       ,Date
       ,SlotName
       ,MonthName
       ,MonthNumberOfYear
       ,Quarter
       ,Year
       ,Semester)
 SELECT 
 *
 ,TO_CHAR(DateSlotStart, 'MONTH') AS [Month_Name]
 ,Extract(month from DateSlotStart) AS [MonthNumberOfYear]
 ,TO_NUMBER(TO_CHAR(DateSlotStart, 'QUARTER')) [Quarter]
 ,Extract(year from DateSlotStart) AS [Year]
 ,CASE WHEN TO_NUMBER(TO_CHAR(DateSlotStart, 'QUARTER')) >6 THEN 2 ELSE 1 
  END [Semester]
  FROM CTE OPTION (MAXRECURSION  0)

0 个答案:

没有答案