Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function A and function B.

Function A Name is f_a() and the code is:

Select id,address from A;

Function B Name is f_b() code is:

Select C.address, 
(Select id,name from B,
(Select * from f_a()) as C 
Where =;

However, when I execute the select * from f_b() the Error message says does not exist. How can I run the function f_a() inside f_b().

Above function A and B are functions which returns table. I omitted the function head and end.

share|improve this question
You're missing a closing parenthesis in function B, can you please correct where it is? – KookieMonster Nov 29 '13 at 9:26
What version of PG? Could use Lateral join for this – Neil McGuigan Nov 29 '13 at 19:01
Please always supply complete function definition including the function header, which is an integral part and probably also part of your problem at hand. – Erwin Brandstetter Dec 1 '13 at 14:41
up vote 0 down vote accepted

Your syntax is twisted in several ways. If the return type of function A is defined as RETURNS TABLE (id int, address text), it could work like this:

Select A.address, 
FROM   f_a() A
JOIN   B USING (id);

Aside: While your identifiers look alright for the purpose, I strictly use legal, lower case identifiers to avoid complications.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.