Skip site navigation (1) Skip section navigation (2)

Re: Accessing fields in a function that returns a set of composite type - How?

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Accessing fields in a function that returns a set of composite type - How?
Date: 2006-04-18 17:46:25
Message-ID: 200604181046.25146@hal.medialogik.com (view raw or flat)
Thread:
Lists: pgsql-novice
On April 18, 2006 10:37 am, "Matt Arnilo S. Baluyos (Mailing Lists)" 
<matt(dot)baluyos(dot)lists(at)gmail(dot)com> wrote:
> To do a full-text search, I only need to do this:
>
> SELECT search('string');
>
> However, running the function gives me a recordset with only one
> column ("search"). I'd like to be able to access the fields of the
> composite type (search_result) that is returned by the function -
> article_id, article_title, headline, and rank. I haven't figured out
> how to do this but it's necessary because I want to be able to control
> the formatting of the output.
>

In general, a set-returning function looks like a table, ie:  

SELECT article_id, article_title, headline, and rank FROM search('string');

Assuming your function works right.  I get an error when trying to call a 
set-returning function as SELECT function();, though, so I don't know how 
yours is doing anything.

-- 
Alan

In response to

pgsql-novice by date

Next:From: Eric Matthew FinninDate: 2006-04-18 17:58:34
Subject: Re: The COPY command and csv files
Previous:From: Matt Arnilo S. Baluyos (Mailing Lists)Date: 2006-04-18 17:45:27
Subject: Re: Accessing fields in a function that returns a set of composite type - How?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group