2

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?

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

This chapter also explains it: postgresql.org/docs/current/static/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.