Re: Question on utility statements and parameterization

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Question on utility statements and parameterization
Дата
Msg-id CAFj8pRA69rth8WQOaMfj1FtzW_5CrtKuPtq5MH90e9+ftEPdhQ@mail.gmail.com
обсуждение исходный текст
Ответ на Question on utility statements and parameterization  (Chris Travers <chris.travers@gmail.com>)
Ответы Re: Question on utility statements and parameterization  (Chris Travers <chris.travers@gmail.com>)
Список pgsql-general
Hello

2011/7/19 Chris Travers <chris.travers@gmail.com>:
> Hi all;
>
> As I understand, utility statements are not generally parameterized, so:
>
> postgres=# alter user test123 with password 'foo' valid until now() +
> '1 day'::interval;
> ERROR:  syntax error at or near "now"
> LINE 1: ...lter user test123 with password 'foo' valid until now() + '1...
>
> Is this by design?  If so, what is the reason?  If not, what would
> have to be done to change this?
>
> Best Wishes,
> Chris Travers
>

If I understand well , a utility has no plan, and a parameters are
implemented as plan's parameters.

you can use a dynamic sql in plpgql

DO $$
BEGIN
  EXECUTE 'ALTER USER test123 WITH PASSWORD 'foo' VALID UNTIL ' ||
to_char(CURRENT_DATE + 1, 'YYYY-MM-DD');
END;
$$;

Regards

Pavel

> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

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

Предыдущее
От: Chris Travers
Дата:
Сообщение: Question on utility statements and parameterization
Следующее
От: Chris Travers
Дата:
Сообщение: Re: Question on utility statements and parameterization