Search Postgresql Archives

setting time zone in a function

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

 



I want the time zone if a function  a bit like ...

CREATE OR REPLACE FUNCTION
   short_name (timestamp with time zone, varchar) RETURNS varchar  AS $$
    DECLARE
        ...
    BEGIN
        SET LOCAL TIME ZONE $2;
        SELECT to_char($1, 'TZ')::varchar
        ...
    END $$
LANGUAGE 'plpgsql' VOLATILE;


But as written is doesn't compile complaining about the "naked" $2. If I quote
the $2 it sets the time zone to $2 literally (I didn't know you could do that,
but that's another issue). Escaping the quotes either as \' or '' doesn't compile.

Help.


Steve


-- 
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