From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | depesz(at)depesz(dot)pl |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: how to return ONE single record from a function in plpgsql? |
Date: | 2003-02-23 16:34:21 |
Message-ID: | 5776.1046018061@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hubert depesz Lubaczewski <depesz(at)depesz(dot)pl> writes:
> i was thinking about using something like:
> CREATE type helper_login as (logged bool, username TEXT, points INT8,
> first_login bool, admin bool, last_login timestamptz, can_ask_questions
> bool, timeleft INTERVAL);
> CREATE OR REPLACE FUNCTION login(TEXT, TEXT, INT8) RETURNS helper_login
> AS '
> DECLARE
> in_username ALIAS FOR $1;
> in_password ALIAS FOR $2;
> in_quiz_id ALIAS FOR $3;
> reply helper_login;
You need to say
reply helper_login%ROWTYPE;
otherwise plpgsql doesn't realize that this is supposed to be a rowtype
variable. (That could stand to be improved, but no one's gotten around
to it yet.) See
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-ROWTYPES
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Eddie Cheung | 2003-02-23 19:02:27 | Help with query involving aggregation and joining. |
Previous Message | Wayne Armstrong | 2003-02-23 11:11:38 | Porting from db2 problem |