Teradata 中 then/else 中的数据类型不匹配

发布于 2025-01-03 07:48:15 字数 327 浏览 0 评论 0原文

我正在检查 y.cap_ts 的内容,如果有值(非空),则将其替换为 current_date 或将其保留为空。但我在 then/else 错误中遇到数据类型不匹配。

这里 cap_ts 是日期数据类型。

任何人都可以建议更好的解决方法吗?

SET  
cap_ts  = CASE WHEN y.cap_ts IS NULL AND y.rwrd > 50  
                THEN current_date  
                ELSE NULL END  

我目前在 Teradata 工作。

I am checking the contents of y.cap_ts and if there is a value (non null) then replace it with current_date or else leave it as null. but I get data type mismatch in then/else error.

Here cap_ts is date data type.

Can any one suggest any better work around?

SET  
cap_ts  = CASE WHEN y.cap_ts IS NULL AND y.rwrd > 50  
                THEN current_date  
                ELSE NULL END  

I am currently working in teradata.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白鸥掠海 2025-01-10 07:48:15

尝试将 CURRENT_DATE 替换为 CURRENT_TIMESTAMP(0)。我知道您说过 CAP_TSDATE 数据类型,但您的命名约定似乎另有说明。与 Oracle 不同,Teradata 中的 DATE 数据类型不包含时间部分。如果它实际上被定义为TIMESTAMP,那么您需要使用CURRENT_TIMESTAMP(n),其中n是时间的精度。

Try replacing CURRENT_DATE with CURRENT_TIMESTAMP(0). I know you said that CAP_TS is a DATE data type but your naming convention seems to indicate otherwise. Unlike Oracle, the DATE data type in Teradata does not include a time component. If it is actually defined as a TIMESTAMP then you need to use CURRENT_TIMESTAMP(n), where n is the precision of the time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文