日期变量在Actian Zen/Perfrasive中是如何声明和使用的?
我如何修复这个
CREATE proc test1 ()
returns(TranDate integer, GLAcntNumber integer , Net decimal(39,19))
as BEGIN
DECLARE :StartDate DATE ;
SELECT CAST('2021-01-01' AS DATE) INTO :StartDate ;
SELECT :StartDate , GLAcntNumber, SUM(Net) AS Amt
FROM vGLBalances
WHERE period < 1
GROUP BY :StartDate, GLAcntNumber;
END
我收回了这一点。我确实从你的询问中看到了一些东西。您正在创建一个DATE,但正试图将其作为整数返回。将您的查询更改为:
CREATE procedure test1 ()
returns(TranDate date, GLAcntNumber integer , Net decimal(39,19))
as BEGIN
DECLARE :StartDate DATE ;
SELECT CAST('2021-01-01' AS DATE) INTO :StartDate ;
SELECT :StartDate, GLAcntNumber, SUM(Net) AS Amt
FROM vGLBalances
WHERE period < 1
GROUP BY :StartDate, GLAcntNumber;
END
它应该起作用。如果您真的想要一个Integer而不是日期,则需要将查询从使用日期更改为使用日期。