plpgsql -- arrays/temporary tables?

Поиск
Список
Период
Сортировка
От Steven D. Arnold
Тема plpgsql -- arrays/temporary tables?
Дата
Msg-id 5.0.2.1.2.20010411002534.04701008@phear.dementian.com
обсуждение исходный текст
Ответы Re: plpgsql -- arrays/temporary tables?  (Anand Raman <araman@india-today.com>)
Список pgsql-general
The following function doesn't work when called multiple times:

CREATE FUNCTION foo(INTEGER) RETURN BOOLEAN AS '
     DECLARE
         y INTEGER;
     BEGIN
         CREATE TEMP TABLE a (
             x INTEGER
         );
         INSERT    INTO a
         VALUES    (4);
         SELECT    INTO y x
         FROM      a;
         DROP TABLE a;
         RETURN TRUE;
     END;
' LANGUAGE 'plpgsql';

I understand that this is because the query plan uses the existing table
`a' repeatedly.

My questions:

* How can I make this work?  Are temporary tables essentially useless
inside plpgsql functions?
* Does plpgsql support array constructs?  How can I use one of these?  How
can I use it in an IN clause?  (Assume the array contained a list of
primary keys.)
* I've considered trying plperl, but I've seen no examples anywhere of how
to execute SQL queries inside plperl!  Any pointers on documentation, or an
example, or anything?  I've combed the search engines for a clue but
haven't found one.

I am using 7.1RC4.  Thanks in advance for any tips!


--
Steven D. Arnold          Que quiero sera         stevena@neosynapse.net
"He was part of my dream, of course -- but then  I was part of his dream
too."                                                   -- Lewis Carroll


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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: Speaking of Indexing... (Text indexing)
Следующее
От: "Francis K Shim"
Дата:
Сообщение: Given: Win98, Cygwin, postgresql-7.0.3.tar.gz | Need: to make libpg/(++) libraries?