开发者

Teradata macro parameter as time interval

This is almost the same problem as Informix defining an INTERVAL with a parameter but is in Teradata.

I'm creating a macro that accepts a string in the form hh:mm:ss to be used as an interval.

The macro wants to do something with a timestamp in the past hh:mm:ss.

Here's the basic 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))
开发者_开发问答)

I get the error Failed 3707: Syntax error, expected something like a string or a Unicode character literal between the 'INTERVAL' keyword and ':'.

Is there a way around this?


Got it.

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));
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜