question about to return two diferent tables from a function

From: hildebardo(at)prodigy(dot)net(dot)mx
To: pgsql-general(at)postgresql(dot)org
Subject: question about to return two diferent tables from a function
Date: 2005-09-24 00:55:32
Message-ID: 70ade270e663.70e66370ade2@prodigy.net.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, I have a question.

I have two tables

first_one

doc|date |id_custumer
1 |2005-09-22| 50
2 |2005-09-21| 50

and the second_one

doc|date |id_code
12 |2005-09-01| 20
13 |2005-09-21| 24
14 |2005-09-22| 31

then I need to join the two tables in a function like this

doc|date |id
1 |2005-09-22| 50
2 |2005-09-21| 50
12 |2005-09-01| 20
13 |2005-09-21| 24
14 |2005-09-22| 31

with just one table I don't have a problem,

CREATE OR REPLACE FUNCTION test_function()
RETURNS setof record
AS 'select * from first_one'
LANGUAGE 'sql';

CH=> select * from test_function() as result(doc int8, date date, id int8);
doc | date | id
-----+------------+----
12 | 2005-09-01 | 20
13 | 2005-09-21 | 24
14 | 2005-09-22 | 31

but I don't know how call the second table.

any help?

Thanks a lot
Luis Hildebardo Moreno
hildebardo(at)prodigy(dot)net(dot)mx
San Luis Potosi, Mexico

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-09-24 01:05:43 Re: Backend crash with user defined aggregate
Previous Message Cristian Prieto 2005-09-23 22:03:11 Index use in BETWEEN statement...