0

Actian Zen/Pervasive 中如何声明和使用日期变量?

我该如何解决

    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
4

1 回答 1

0

我收回之前说过的话。我确实在您的查询中看到了一些东西。您正在创建一个 DATE,但正试图将其作为 INTEGER 传回。将您的查询更改为:

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

它应该工作。如果您真的想要整数而不是日期,则需要将查询更改为使用日期。

于 2021-06-11T23:46:35.627 回答