Re: Isolating a record column from a PL-Pgsql function call ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Isolating a record column from a PL-Pgsql function call ?
Date: 2008-12-17 00:28:04
Message-ID: 18061.1229473684@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> writes:
> I have a PL-Pgsql function that returns a record of a type that have 4 elements (columns). Let's say the first element/column is called "id_num". Is there a way I can specify the id_num element of the record returned from iside a query?

> For example, select col1 from thetable where my_plpgsql_fn(col2).id_num = 123;

You're just missing some parentheses:

select col1 from thetable where (my_plpgsql_fn(col2)).id_num = 123;

as indeed is documented here:
http://www.postgresql.org/docs/8.3/static/sql-expressions.html#AEN1679

There are messy syntactic reasons for requiring these parens, which
I don't recall the details of at the moment ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-12-17 00:47:14 Re: TIMESTAMP with a timezone offset
Previous Message Hoover, Jeffrey 2008-12-16 21:48:27 Re: Need help to dynamically access to colomns in function!