From: | "Alain Roger" <raf(dot)news(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | SELECT statement in stored procedure |
Date: | 2006-07-01 16:08:19 |
Message-ID: | 75645bbb0607010908m6845fee7x9b4cd302478c49c4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have the following stored procedure :
CREATE OR REPLACE FUNCTION immense_sp001(IN username VARCHAR, IN
strhash VARCHAR)
RETURNS SETOF accounts LANGUAGE plpgsql
AS '
DECLARE
Profile_Detected INTEGER :=0;
act accounts%ROWTYPE;
rec RECORD;
BEGIN
/* detect if the user logged in exists in database*/
SELECT count(*) INTO Profile_Detected FROM accounts
WHERE login=username AND pwd=strhash;
if (Profile_Detected = 1) then
SELECT INTO act * FROM accounts;
FOR rec IN select login,status from accounts LOOP
RETURN NEXT rec;
END LOOP;
end if;
return;
END;
';
so it should return only 2 fields from my account table (login and status).
however it does not work.
if i replace the line "FOR rec IN select login,status from accounts LOOP" by
FOR rec IN select * from accounts LOOP
it works but i get all fields from my accounts table.
So how can i get only login and status ?
thanks a lot,
Alain
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2006-07-01 16:53:06 | Re: Dynamic technical graphics generation inside plperl query? |
Previous Message | Ron Johnson | 2006-07-01 15:46:33 | Re: db question - dynamic fields in db |