Re: plpgsql question

Поиск
Список
Период
Сортировка
От Matthew Peter
Тема Re: plpgsql question
Дата
Msg-id 20060106091438.69917.qmail@web35201.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: plpgsql question  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: plpgsql question  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general

Michael Fuhr <mike@fuhr.org> wrote:
On Thu, Jan 05, 2006 at 12:50:34AM -0800, Matthew Peter wrote:
> Is it possible to skip the loop and just return all records in a
> single query and shove all those rows into a table variable?

Not in PL/pgSQL -- you need to return each row with RETURN NEXT,
generally from within a loop. Why do you want to avoid that?
I was thinking it would be more efficient to pull all the records in one call rather than 50 calls. For all I know it probably executes 50 calls in the internals when translating the IN (IDs).
* You could use an IF statement to execute the query you need.
That's what I was trying to do, but I'm no t sure i was doing it in the right context, since it was IN the query, not testing after it. Figured I'd ask the list if I was trying something impossible or if I was close to help get me on track.
* You could put the queries in separate functions.
The query is so similiar (occasionally match on extra WHERE arg) it would be nice just to use a conditional to match if that extra argument is given as not null...rather than maintain two simliar functions if possible, while keeping it planned after the first run.

Does using an IF predicate in the WHERE in the SQL call require EXECUTE since (I guess) I'm making the SQL statement somewhat dynamic? All I've been able to find is IF handling after the query, not in it.

Thanks again

Matt


Yahoo! DSL Something to write home about. Just $16.99/mo. or less

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

Предыдущее
От: Bjørn T Johansen
Дата:
Сообщение: Re: Hardware recommendation for PostgreSQL on Windows?
Следующее
От: mordicus
Дата:
Сообщение: Problems building pg 8.1.1