SELECT INTO Troubles

Поиск
Список
Период
Сортировка
От Brian Troxell
Тема SELECT INTO Troubles
Дата
Msg-id 3A5A4901.A6E9BA05@mindspring.com
обсуждение исходный текст
Ответы Re: SELECT INTO Troubles
Список pgsql-general
Hello again everyone. This is the next message in my series of troubles
regarding EXECUTE and SELECT INTO (or CREATE TABLE). Hopefully the list
will be as helpful and informative as with my previous queries.

I have a PG/plSQL function get_attribute()) that does a simple lookup
using this code:
EXECUTE ''CREATE TEMPORARY TABLE random_tab (item) AS SELECT '' ||
       quote_ident(v_column) || '' FROM '' ||
       quote_ident(v_table_name) || '' WHERE '' || v_key_sql;
v_return := random_tab.item;
raise NOTICE ''v_return = %'', v_return;
DROP TABLE random_tab;

In my test routine, I call this get_attribute() function, followed by
another set_attribute() function, followed by get_attribute() again to
make sure the value was changed.

The problem is with the second call to get_attribute()...I get this
error:
psql:lop2:15: ERROR:  Relation 74176 does not exist

But if I remove the DROP TABLE statement from the get_attribute()
function, the second call to it fails with this error:
psql:lop2:15: ERROR:  Relation 'random_tab' already exists

So I tried it again, taking out the EXECUTE and just hard-coding the
SELECT statement, and get the same errors.

This sounds like a total Catch-22 to me, which must mean I'm doing
something wrong. Help!!!!!

Thanks in advance!

Brian Troxell
trox@mindspring.com

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

Предыдущее
От: Webb Sprague
Дата:
Сообщение: Tuning questions, and an offer
Следующее
От: "imago"
Дата:
Сообщение: Re: DROP SEQUENCE ?