X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2976F475CB1 for ; Sun, 23 Feb 2003 11:48:59 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 81951-03 for ; Sun, 23 Feb 2003 11:48:48 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 48A7C47590C for ; Sun, 23 Feb 2003 11:34:25 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h1NGYL5u005777; Sun, 23 Feb 2003 11:34:22 -0500 (EST) To: depesz@depesz.pl Cc: pgsql-sql@postgresql.org Subject: Re: how to return ONE single record from a function in plpgsql? In-reply-to: <20030223104731.GD11016@depesz.pl> References: <20030223104731.GD11016@depesz.pl> Comments: In-reply-to Hubert depesz Lubaczewski message dated "Sun, 23 Feb 2003 11:47:31 +0100" Date: Sun, 23 Feb 2003 11:34:21 -0500 Message-ID: <5776.1046018061@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/509 X-Sequence-Number: 11907 Hubert depesz Lubaczewski 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