Search Postgresql Archives

psql \set variables in crosstab queries?

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

 




According to https://www.postgresql.org/docs/12/app-psql.html#APP-PSQL-VARIABLES and experience, variables don't interpolate inside of string literals:
"
Variable interpolation will not be performed within quoted SQL literals and identifiers. Therefore, a construction such as ':foo' doesn't work to produce a quoted literal from a variable's value.
"

$ psql12 -v BOM=2023-02-01 -af foo.sql
select :'BOM'::timestamp + interval'6 month';
      ?column?
---------------------
 2023-08-01 00:00:00
(1 row)

select $$ :BOM $$;
 ?column?
----------
  :BOM
(1 row)

But crosstab takes text strings as parameters.  How then do you use \set variables in crosstab queries?

--
Born in Arizona, moved to Babylonia.





[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 Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux