Skip site navigation (1) Skip section navigation (2)

Function problem

From: "Oscar Chavarria" <cyberbuzzard(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Function problem
Date: 2007-04-09 14:16:10
Message-ID: 716841580704090716g2b19193fm3f4a06c463649067@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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

Responses

pgsql-novice by date

Next:From: Stephan SzaboDate: 2007-04-09 14:32:13
Subject: Re: Function problem
Previous:From: Tom LaneDate: 2007-04-08 23:16:35
Subject: Re: Odd Timestamp Error WAS Re: Function Creation Error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group