Function returns error (view) - Mailing list pgsql-sql

From Professor Flávio Brito
Subject Function returns error (view)
Date
Msg-id 6a5e3a6f0802260832k9c1375ap632f8adad0740fa2@mail.gmail.com
Whole thread Raw
Responses Re: Function returns error (view)
Re: Function returns error (view)
List pgsql-sql
Hi<br /><br />Don't know why I can't receive a return like my view fields (I'm newbie in plpgsql). Postgresql returns
mea erro . How can I received a answer like my view structure?<br /><br />When I Test my view I receive <br /><br
/>SELECT seach_password('user_login_foo')<br /><br /> My view returns me<br /><br /><font size="1"> 25746;"MARCELO
";"bio1";"bio1";"2008-02-19";"FALSE";"2008-02-12";"2008-02-1212:51:40.229282";"TRUE"<br /> 30356;"JOSE DE JESUS
";"977";"377";"2008-02-19";"FALSE";"2008-02-12";"2008-02-1212:52:19.688381";"TRUE"<br /></font><br /> It's OK<br /><br
/>but when I use function it returns me<br /><br /> ERROR: column "user_login_foo" does not exist<br /> SQL state:
42703<br/> Context: PL/pgSQL function "search_password" line 14 at for over execute statement<br /><br /> Where is my
fault?<br/><br />Thanks<br /><br />Flávio <br /><br
/>*************************************************************************************************************<br
/>vw_change_password attributes<br /><br />cod_user integer,<br /> user_name varchar(150),<br />openpsw varchar
(32),<br/>user_password varchar (50),<br />end timestamp,<br />validate boolean,<br />date_add timestamp,<br
/>user_timetimestamp,<br />ok boolean<br /><br /><br />CREATE OR REPLACE FUNCTION seach_password(USER_FOO
varchar(100))<br/> RETURNS SETOF vw_change_password AS <br />$BODY$<br />DECLARE <br />r vw_change_password%ROWTYPE;<br
/>USER_FOOalias for $1;<br />sql TEXT;<br />BEGIN<br />sql= 'SELECT u.cod_user, u.user_name, u.openpsw,
t.user_password,t.end, t.validate, t.date_add, t.user_time, u.ok<br />    FROM usuario u, change_user_password t<br /> 
WHEREu.cod_user = t.cod_user  AND t.cod_user <br />    IN <br />    (SELECT cod_user <br />        FROM table_user <br
/>           WHERE login='||USER_FOO||')';<br /><br /> FOR r IN EXECUTE sql<br /> LOOP<br /> RETURN NEXT r;<br />END
LOOP;<br/> IF NOT FOUND THEN<br />        RAISE EXCEPTION 'USER not found', USER_FOO;<br /> END IF;<br /> RETURN;<br
/> END<br/> $BODY$<br />  LANGUAGE 'plpgsql' VOLATILE;<br /><br /><br /> 

pgsql-sql by date:

Previous
From: Teemu Torma
Date:
Subject: Re: duplicate key violates unique constraint
Next
From: "Bart Degryse"
Date:
Subject: Re: duplicate key violates unique constraint