Reputation: 5684
Table FOO
has columns A and B
Table BAR
has columns X, Y and Z
.
I have a function func
that returns a ROWTYPE of table BAR
FUNCTION func(arg1, arg2) RETURNS BAR
I want to do something like this
select A,B, func(A,B).X from FOO;
But it fails with the following error:
syntax error at or near "."
However, if I do not not use .<column_name>
after the function, then it serializes the entire RECORD returned by the function as text.
How do I choose just X
instead of all constituent fields?
Upvotes: 2
Views: 1303
Reputation: 5684
Found it.
You need to enclose the function call in brackets and then use a .
This fails:
select A,B, func(A,B).X from FOO;
This works:
select A,B, (func(A,B)).X from FOO;
http://www.postgresql.org/docs/current/static/rowtypes.html
Upvotes: 3