Hi all,

I¹m having difficulty using variable interpolation within psql, where that
variable is within a table nameŠ


Like so..

=# set YYYYMM 201310
=# select :YYYYMM;
 ?column?
----------
   201309
(1 row)


=# alter table my_table rename to my_table_:YYYYMM_raw;
ERROR:  syntax error at or near ":"
LINE 1: Šmy_table rename to my_table_:YYYYMM_ra...
                                     ^

The problem is that psql tries to interpret ŒYYYYMM_raw¹ as the variable
name, but my intention is to only interpret ŒYYYYMM¹ followed by a literal
underscore.

I can¹t find any other way to encapsulate the variable name in this wayŠ  Is
there a trick to it?

I suspect I¹ll need to work around this by altering the naming convention
such that the YYYYMM is at the Œend¹ of the table name.  Maybe..   Thoughts?


Tim





Reply via email to