question about to return two diferent tables from a function

Поиск
Список
Период
Сортировка
От hildebardo@prodigy.net.mx
Тема question about to return two diferent tables from a function
Дата
Msg-id 70ade270e663.70e66370ade2@prodigy.net.mx
обсуждение исходный текст
Ответы Re: question about to return two diferent tables from a function  (Michael Fuhr <mike@fuhr.org>)
Список 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@prodigy.net.mx
San Luis Potosi, Mexico

В списке pgsql-general по дате отправления:

Предыдущее
От: Tony Wasson
Дата:
Сообщение: Re: Getting the amount of overlap when using OVERLAPS
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Backend crash with user defined aggregate