Re: [GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread Bosco Rama
On 11/08/13 09:30, Tim Kane wrote: > > Remi, to answer your question - this is being called as part of a shell > script. In that case your options expand greatly... For example: tbl_name="MM" psql -c "alter table my_table rename to my_table_${tbl_name}_raw;" or for more complex stuff

Re: [GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread John R Pierce
On 11/8/2013 9:57 AM, Bosco Rama wrote: On 11/08/13 09:30, Tim Kane wrote: > >Remi, to answer your question - this is being called as part of a shell >script. In that case your options expand greatly... I'd still suggest perl for this, especially if it is ever going to get even a little bit

Re: [GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread Tim Kane
On 08/11/2013 16:47, "Adrian Klaver" wrote: >> >test=> \set tbl_name 'my_table_':MM'_raw'; > >test=> alter table my_table rename to :tbl_name; >ALTER TABLE > >test=> \d my_table_201310_raw >Table "public.my_table_201310_raw" > Column | Type | Modifiers >+-+--- >

Re: [GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread Adrian Klaver
On 11/08/2013 08:08 AM, Tim Kane wrote: Hi all, I’m having difficulty using variable interpolation within psql, where that variable is within a table name… Like so.. =# set MM 201310 =# select :MM; ?column? -- 201309 (1 row) =# alter table my_table rename to my_table_:

Re: [GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread Rémi Cura
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 > Hi all, > > I’m having difficulty using variable interpolation within psql, where that > variable is within a ta

[GENERAL] psql variable interpolation with subsequent underscore

2013-11-08 Thread Tim Kane
Hi all, I¹m having difficulty using variable interpolation within psql, where that variable is within a table nameŠ Like so.. =# set MM 201310 =# select :MM; ?column? -- 201309 (1 row) =# alter table my_table rename to my_table_:MM_raw; ERROR: syntax error at or near