pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guru Prasad <pnguruji@yahoo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Cc: Radhika Vutukuru <rvutukur@saraf.com>
Subject: Re: working with stored procedures (fwd)
Date: Tue, 15 May 2001 18:40:49 +0530 (IST)
Message-ID: <Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks> (raw)


> regy1'> output_rec := user_rec;

Here you can't assign the entire record (user_rec) into a variable. You
can assign either one of the following.

1. output_rec := user_rec.fname;
2. output_rec := user_rec.lname;
3. output_rec := user_rec.fname || user_rec.lname (This will concantenate
the two fields of same data type. I am not sure whether you will require
this).

I hope this will solve your problem.

Regards,
guru.

bk SYSTEMS (P) Ltd.
                                                    P . N . G U R U P R A S A D
-------------------------------------------------------------------------------



On Mon, 14 May 2001, Radhika Vutukuru wrote:

> Hi ,
> I am trying to create a stored procedure that returns a user defined type. The following piece of code shows the way I am trying to do it.
> regy1=> create function regyuser_rec(int) returns varchar as ' declare
> regy1'> v_userid alias for $1;
> regy1'> output_rec varchar(400);
> regy1'> user_rec record;
> regy1'> 
> regy1'> begin
> regy1'> 
> regy1'> select fname ,lname into user_rec from regyuser
> regy1'>  where userid = v_userid;
> regy1'> output_rec := user_rec;
> regy1'> return output_rec;
> regy1'> end;
> regy1'> ' language 'plpgsql';
> CREATE
> regy1=> select regyuser_rec(2);
> ERROR:  Attribute 'user_rec' not found
> 
> Does a postgresql function returns a user defined object?
> If so, could I have an example.
> I am new to postgresql, and was trying to figure out what's wrong with my code.Could some one help me.
> Thanks,
> Radhika.
> 






Message-ID: <Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks>
Permalink:  ../Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks/
Also on:    postgresql.org/message-id/Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pnguruji@yahoo.com, rvutukur@saraf.com
  Subject: Re: working with stored procedures (fwd)
  In-Reply-To: <Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks>
  References: <Pine.LNX.4.20.0105151839030.22364-100000@Larry.bks>

* 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