Hi all,
I have a monster function full of IF ELSIF branches that is supposed
to return a SETOF value, though regardless of its route through the
logic it only returns an empty row.
Fortunately, reduced to almost nothing I have the sme problem so it
will likely be a simply matter. Function and table definition follow:
CREATE TABLE ForecastData(type TEXT, item TEXT, descr TEXT, unit TEXT,
qty FLOAT, rate FLOAT, amt FLOAT);
CREATE OR REPLACE FUNCTION CreateDefaultForecasts(INTEGER) RETURNS
SETOF ForecastData AS '
BEGIN
RETURN (SELECT ''old'' as type, ''item'' as item, ''descr'' as
descr, ''unit'' as unit, 0 as qty, 0 rate, 0 as amt);
END;
' LANGUAGE 'plpgsql';
dbtestvanek=# select * from CreateDefaultForecasts(314028);
type | item | descr | unit | qty | rate | amt
------+------+-------+------+-----+------+-----
(0 rows)
The actual function inserts into ForecastData and then returns (SELECT
* from ForecastData where type = ''new''); or rather should do, but no
matter what it returns the same 0 rows.
What am I doing wrong, and, bonus question, where should I have found
the answer in the docs?
Thanks for your time and attention!
Coby
psql 7.4.27 on a Linux server.