pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fernando Hevia <fhevia@ip-tel.com.ar>
To: 'Bart Degryse' <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Subject: Re: NO DATA FOUND Exception
Date: Tue, 26 Jun 2007 13:15:16 -0300
Message-ID: <053b01c7b80d$2ebb9740$8f01010a@iptel.com.ar> (raw)
In-Reply-To: <468140AB.A3DD.0030.0@indicator.be>


>>"Fernando Hevia" <fhevia@ip-tel.com.ar> 2007-06-26 16:25 >>>
>>How do I refer a specific field of the returned row from outside the
>>function? How should I write the query in order to show only fields 1 and
3, for example?

>In case you would like to use set returning functions...
> 
>if your function will return records with the same structure as an existing
>table
>CREATE FUNCTION my_func() RETURNS SETOF my_table AS ...
> 
>if not you have to define the returning type
>CREATE TYPE func_row AS ("field1" varchar(10), "field2" integer, "field3"
>integer, ...)
>CREATE FUNCTION my_func() RETURNS SETOF func_row AS ...
>
>now you can use your function
>SELECT * FROM my_func();
> 
>or
> 
>SELECT A.field1, A.field2
>FROM my_func() A left join my_func() B on A.field2 = B.field3
>WHERE A.field1 like 'B%';


Exactly what I was looking for. 
Thanks!!




view thread (7+ messages)

Message-ID: <053b01c7b80d$2ebb9740$8f01010a@iptel.com.ar>
Permalink:  ../053b01c7b80d$2ebb9740$8f01010a@iptel.com.ar/
Also on:    postgresql.org/message-id/053b01c7b80d$2ebb9740$8f01010a@iptel.com.ar

 · 

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: fhevia@ip-tel.com.ar, Bart.Degryse@indicator.be
  Subject: Re: NO DATA FOUND Exception
  In-Reply-To: <053b01c7b80d$2ebb9740$8f01010a@iptel.com.ar>

* 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