Re: RE: pl/pgsql and returning rows

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Jeff Eckermann" <jeckermann(at)verio(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>, "wade" <wade(at)wavefire(dot)com>
Subject: Re: RE: pl/pgsql and returning rows
Date: 2001-03-28 10:23:51
Message-ID: 007501c0b771$b0964740$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>

> MY book in chapter 18 has a Pl/PgSQL function called change_statename
> that does insert/update automatically.
>
> http://www.postgresql.org/docs/awbook.html

The functions called get_details though, so I assumed it's supposed to be
shorthand for a join.

- Richard

> > As a workaround, you can insert your row into an existing table, then
> > retrieve it from there later. I think you need to enumerate all of the
> > fields, as in 'INSERT INTO table VALUES (ret.field1,
> > ret.field2,...ret.fieldn);'. At least, I haven't succeeded any other
way.
> > Messy, but the best method available right now.
> >
> > > -----Original Message-----
> > > From: Richard Huxton [SMTP:dev(at)archonet(dot)com]
> > > Sent: Tuesday, March 27, 2001 2:27 AM
> > > To: pgsql-sql(at)postgresql(dot)org; wade
> > > Subject: Re: pl/pgsql and returning rows
> > >
> > > From: "wade" <wade(at)wavefire(dot)com>
> > >
> > > > create function get_details(int4) returns details as '
> > > > declare
> > > > ret details%ROWTYPE;
> > > > site_rec record;
> > > > cntct contacts%ROWTYPE;
> > > > begin
> > > > select into site_rec * sites_table where id = $1 limit 1;
> > > > select into cntct * from contacts where id = site_rec.contact;
> > > >
> > > > -- and then i populate rows of ret.
> > > > ret.name := cntct.name;
> > > > ret.ip := site_rec.ip;
> > > > .
> > > > .
> > > > .
> > > > return ret;
> > > > end;
> > > > ' language 'plpgsql';
> > > >
> > > > now the problem is when is when I do a:
> > > > SELECT get_details(55);
> > > > all i get is a single oid-looking return value:
> > > > get_details
> > > > -------------
> > > > 136295592
> > > > (1 row)
> > >
> > > Sorry - you can't return a row from a function at the present time
(except
> > > for trigger functions which are special) although I believe this is on
the
> > > todo list for a later 7.x release.
> > >
> > > Just from the top of my head, you might try a view with a select rule,
> > > although I'm not completely clear what your objectives are.
> > >
> > > - Richard Huxton
> > >
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 1: subscribe and unsubscribe commands go to
majordomo(at)postgresql(dot)org
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
>
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Salvador Mainé 2001-03-28 10:52:45 date_part bug?
Previous Message chris Gnther 2001-03-28 09:50:51 DELETE FROM fails with error