Re: psql variable interpolation with subsequent underscore

Поиск
Список
Период
Сортировка
От Rémi Cura
Тема Re: psql variable interpolation with subsequent underscore
Дата
Msg-id CAJvUf_tx=+o2--m=fdKbEjNDfczc0WJ=tWM82TXROJf9Rp7tow@mail.gmail.com
обсуждение исходный текст
Ответ на psql variable interpolation with subsequent underscore  (Tim Kane <tim.kane@gmail.com>)
Список pgsql-general
maybe a stupid answer, 
but why not use another language (plpgsql? python?).
Is it because of transaction issue?
Sorry for not being more helpfull.
Cheers,
Rémi-C


2013/11/8 Tim Kane <tim.kane@gmail.com>
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




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

Предыдущее
От: Tim Kane
Дата:
Сообщение: psql variable interpolation with subsequent underscore
Следующее
От: zach cruise
Дата:
Сообщение: Re: upgrading to 9.3