我有一个存储过程,它返回0个结果,但是如果单独运行查询,则会返回很多结果。我错过了什么。
CREATE OR REPLACE FUNCTION countStatistics(baselineDate Date) RETURNS int AS $$
DECLARE
qty int;
BEGIN
SELECT COUNT(*) INTO qty FROM statistics WHERE time_stamp = baselineDate;
RETURN qty;
END;
$$ LANGUAGE plpgsql;
--Execute the function
SELECT countStatistics('2015-01-01 01:00:00') as qty;
返回0个结果
SELECT COUNT(*) FROM statistics WHERE time_stamp = '2015-01-01 01:00:00';
返回100+结果