pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: depesz@depesz.pl
Cc: pgsql-sql@postgresql.org
Subject: Re: how to return ONE single record from a function in plpgsql?
Date: Sun, 23 Feb 2003 11:34:21 -0500
Message-ID: <5776.1046018061@sss.pgh.pa.us> (raw)
In-Reply-To: <20030223104731.GD11016@depesz.pl>
References: <20030223104731.GD11016@depesz.pl>

Hubert depesz Lubaczewski <depesz@depesz.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-DECLAR...

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <5776.1046018061@sss.pgh.pa.us>
Permalink:  ../5776.1046018061@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5776.1046018061@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, depesz@depesz.pl
  Subject: Re: how to return ONE single record from a function in plpgsql?
  In-Reply-To: <5776.1046018061@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox