这与Informix defining an INTERVAL with a parameter几乎相同,但在Teradata中。
我正在创建一个宏,它接受hh:mm:ss形式的字符串作为间隔。
宏想要用过去的时间戳做某事hh:mm:ss。
这是基本的sql
CREATE MACRO TEST_MACRO (
HHMMSS CHAR(8)
)
AS
(
SELECT
CAST(CURRENT_TIME AS TIMESTAMP(0)),
CAST(CURRENT_TIME - INTERVAL :HHMMSS HOUR TO SECOND AS TIMESTAMP(0))
)
我收到错误Failed 3707: Syntax error, expected something like a string or a Unicode character literal between the 'INTERVAL' keyword and ':'
。
有解决方法吗?
答案 0 :(得分:1)
知道了。
CREATE MACRO TEST_MACRO (
HHMMSS CHAR(8)
)
AS
(
SELECT
CAST(CURRENT_TIME AS TIMESTAMP(0)),
CAST(CURRENT_TIME - CAST(:HHMMSS AS INTERVAL HOUR TO SECOND) AS TIMESTAMP(0));
)