Re: [GENERAL] psql \echo strangeness with :variables
In article <[EMAIL PROTECTED]>, Jerry Sievers <[EMAIL PROTECTED]> wrote: % [EMAIL PROTECTED] % = \set date `date '+%Y%m%d'` % % [EMAIL PROTECTED] % = \echo :date % 20060524 % % [EMAIL PROTECTED] % = \echo foo_:date % foo_:date <-- Was expecting this to expand... see below variables need to be space-delimited in \ contexts. Work-around: \set tn 'foo_' :date \echo :tn create table :tn(); -- Patrick TJ McPhee North York Canada [EMAIL PROTECTED] ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[GENERAL] psql \echo strangeness with :variables
Hello. Today I used a shell call in psql to save the runtime date in a psql variable and use this to dynamically create tables with date encoded in table name. For some reason however, the psql \echo command can't expand the date though it does expand in the calls to the backend. See example below; [EMAIL PROTECTED] = \set date `date '+%Y%m%d'` [EMAIL PROTECTED] = \echo :date 20060524 [EMAIL PROTECTED] = \echo foo_:date foo_:date <-- Was expecting this to expand... see below [EMAIL PROTECTED] = create table foo_:date(); CREATE TABLE [EMAIL PROTECTED] = \dt List of relations Schema | Name | Type | Owner +--+---+-- public | foo_20060524 | table | jsievers (1 row) Seems there's a bit of asymmetry in the way psql evaluates the :variables. FYI -- --- Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant 305 321-1144 (mobilehttp://www.JerrySievers.com/ ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org