我在MS SQL中创建了一个视图。它工作得很好。当我将项目导出并导入Oracle环境时,视图不再起作用。据我所知,我使用了META SQL。
希望有人可以提供帮助!
SELECT OPRID
, DESCR1
, DESCR
, DESCR5
, DESCR6
, DESCR7
, YEAR
, WEEKOFYEAR
--When working more then 6 hours, subtract .5 hours break
, CASE WHEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_MONDAY_START
, DG_MONDAY_END))/60) >= 6 THEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_MONDAY_START
, DG_MONDAY_END))/60 - 0.5) ELSE (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_MONDAY_START
, DG_MONDAY_END))/60) END AS 'MONDAY'
, CASE WHEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_TUESDAY_START
, DG_TUESDAY_END))/60) >= 6 THEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_TUESDAY_START
, DG_TUESDAY_END))/60 - 0.5) ELSE (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_TUESDAY_START
, DG_TUESDAY_END))/60) END AS 'TUESDAY'
, CASE WHEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_WEDNESDAY_START
, DG_WEDNESDAY_END))/60) >= 6 THEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_WEDNESDAY_START
, DG_WEDNESDAY_END))/60 - 0.5) ELSE (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_WEDNESDAY_START
, DG_WEDNESDAY_END))/60) END AS 'WEDNESDAY'
, CASE WHEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_THURSDAY_START
, DG_THURSDAY_END))/60) >= 6 THEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_THURSDAY_START
, DG_THURSDAY_END))/60 - 0.5) ELSE (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_THURSDAY_START
, DG_THURSDAY_END))/60) END AS 'THURSDAY'
, CASE WHEN(CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_FRIDAY_START
, DG_FRIDAY_END))/60) >= 6 THEN (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_FRIDAY_START
, DG_FRIDAY_END))/60 - 0.5) ELSE (CONVERT(DECIMAL(10,1)
, DATEDIFF(MINUTE
, DG_FRIDAY_START
, DG_FRIDAY_END))/60) END AS 'FRIDAY'
, '0' AS 'TOTAL'
--Total will be calculated in PeopleCode
FROM PS_DG_BPV_ROSTER
WHERE YEAR LIKE YEAR(TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD'))
AND (DG_MONDAY_START != DG_MONDAY_END
OR DG_TUESDAY_START != DG_TUESDAY_END
OR DG_WEDNESDAY_START != DG_WEDNESDAY_END
OR DG_THURSDAY_START != DG_THURSDAY_END
OR DG_FRIDAY_START != DG_FRIDAY_END)
答案 0 :(得分:2)
在您的查询中,您使用CONVERT
命令,但在Oracle中,您必须使用CAST
。
必须使用NUMBER类型更改DECIMAL类型,如下所示。
而不是:
CONVERT(DECIMAL(10,1), field)
使用:
CAST(field as NUMBER(10,1))
告诉我它是否正常
编辑评论后
在Oracle中,Sql Server函数DATEDIFF已替换为-
符号,作为两个DATA字段之间的正常差异。
我建议你site在哪里可以找到Oracle 10g和Sql Server 2008R2之间的等效功能