I would appreciate and thank in advance any help to understand the error message I receive when I try to run this function. The function is initially accepted with no errors of syntax.
CREATE OR REPLACE FUNCTION returns_todate(integer)
RETURNS numeric AS
$BODY$
DECLARE
yield_rows investments%rowtype;
counter integer;
sum_returns numeric;
BEGIN
FOR yield_rows IN SELECT * FROM investments
LOOP
sum_returns:=investments.return1+investments.return2+investments.return3+investments.return4+investments.return5+investments.return6+investments.return7 ;
INSERT INTO investments(returns_to_date) VALUES(sum_returns);
END LOOP;
return counter;
END
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
SELECT returns_todate(5);
ERROR: missing FROM-clause entry for table "investments"
_____________________________
Regards
Oscar Chavarria
Mobile: +506 814-0247