Re: can a function return a virtual table?

Поиск
Список
Период
Сортировка
От Kai Hessing
Тема Re: can a function return a virtual table?
Дата
Msg-id 3cmebiF6n5ocpU1@individual.net
обсуждение исходный текст
Ответ на Re: can a function return a virtual table?  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-sql
Hi,

and thanks for the answer  ;)  (*upps* just noticed, that I sent the
answer accidently direct to poster^^ *sorry*)

Michael Fuhr schrieb:

>> I'll pick a nit and point out that the above isn't a valid query:
>>
>> test=> SELECT xyz, abc FROM (SELECT * FROM tablex WHERE status > -1);
>> ERROR:  subquery in FROM must have an alias
>> HINT:  For example, FROM (SELECT ...) [AS] foo.

*yeah* sure you're right. I shortened it to much^^


>> In this simple example you could omit the subquery altogether:
>> SELECT xyz, abc FROM tablex WHERE status > -1;

It is not about such a simple example. When joining tables (especially
with outer joins) it isn't trivial  ;)

>> See the documentation for writing set-returning functions (SRFs).
>> The following links should get you started (if you're using a version
>> of PostgreSQL older than 8.0, then see the documentation for that
>> version):

Thanks, I think this is what I've searched for (btw. we use 7.3). But
what I want to do is:

CREATE FUNCTION active(char) RETURNS setof $1 AS '   SELECT * FROM $1 WHERE status>-1;
' LANGUAGE SQL;

But this does not work. So I'll use views instead  ;)  It also should be
more performant. Thanks...


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

Предыдущее
От: "amit kumar awasthi"
Дата:
Сообщение: How to configure postgresql to accept TCP/IP connections
Следующее
От: "Ramakrishnan Muralidharan"
Дата:
Сообщение: Re: string to date conversion