plpgsql function question

Поиск
Список
Период
Сортировка
От Scott Geller
Тема plpgsql function question
Дата
Msg-id h2ic598163c1004032219hbd347706o4e424bf515ce2e71@mail.gmail.com
обсуждение исходный текст
Ответы Re: plpgsql function question  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-novice

Hi

I am learning plpgsql and am getting errors on this simple function:

CREATE OR REPLACE FUNCTION test2(tab1 text, tab2 text )
  RETURNS text AS
  $$
  BEGIN
  EXECUTE 'create table ' || quote_ident(tab2) || ' as Select *  from ' || quote_ident(tab1);
    RETURN 'done';
  END; $$
  LANGUAGE 'plpgsql' VOLATILE;

Yet, when I replace tab1 & tab2 in the execute statement it works just fine:

CREATE OR REPLACE FUNCTION test2(tab1 text, tab2 text )
  RETURNS text AS
  $$
  BEGIN
  EXECUTE 'create table ' || quote_ident($2) || ' as Select *  from ' || quote_ident($1);
    RETURN 'done';
  END; $$
  LANGUAGE 'plpgsql' VOLATILE;

Any insight would be appreciated!

Thanks

Scott

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

Предыдущее
От: Mladen Gogala
Дата:
Сообщение: Re: slow plan on join when adding where clause
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: plpgsql function question