Search Postgresql Archives

Re: Question on utility statements and parameterization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2011/7/19 Chris Travers <chris.travers@xxxxxxxxx>:
> 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@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux