尝试获取变量作为偏移值,但又返回错误,有帮助吗? 谢谢
set offset_number = (select to_number(datediff(second,current_timestamp(),min("created_at"))*-1) from "PRESENTATION"."DWH"."TABLE");
-- 1607610
select $offset_number;
-- 1607610
select * from "STAGING"."DWH_STAGING"."S_TRADES" at(offset => $trade_date);
-- SQL compilation error: Invalid data type [$offset_number] in AT(OFFSET => $offset_number)
答案 0 :(得分:0)
假设这是复制/粘贴错误:at(offset => $trade_date)
当您的错误消息引用了$offset_number
时。
如果将offset_number显式转换为整数怎么办?
set offset_number = (
select to_number(datediff(second,current_timestamp(),min("created_at"))*-1)
from "PRESENTATION"."DWH"."TABLE")::integer;
或
select * from "STAGING"."DWH_STAGING"."S_TRADES"
at(offset => $offset_number::integer);
-保罗-