Обсуждение: psql dynamic comments

Поиск
Список
Период
Сортировка

psql dynamic comments

От
"Little, Douglas"
Дата:

I’m trying to generate a comment on all my changes – so I know when they were completed.

 

Does anybody have anything that does this.

 

I think the psql script is something like

 

d1gp1=> \set currtime `date '+20%y-%m-%d %H:%M:%S'`

d1gp1=> \echo :currtime

2010-10-06 10:01:51

 

d1gp1=> comment on index mdm_mart_tbls.mdm_gotoastcampaignevt_pk is 'created by dwda-1618 on :currtime';

COMMENT

 

 

Unfortunately the variable doesn’t get replaced due to the quotes.

COMMENT ON INDEX mdm_mart_tbls.mdm_gotoastcampaignevt_pk IS 'created by dwda-1618 on :currtime';

 

I’ve tried various options,  2,3,4 quotes.  Concatenation, Building the entire string as the variable.  But nothing seems to work.

 

Any suggestions?

 

Thanks in advance.

Doug

 

Doug Little

 

Sr. Data Warehouse Architect | Enterprise Data Management | Orbitz Worldwide

500 W. Madison, Suite 1000  Chicago IL 60661| Office 312.260.2588 | Fax 312.894.5164 | Cell 847-997-5741

Douglas.Little@orbitz.com

 cid:image001.jpg@01CABEC8.D4980670  orbitz.com | ebookers.com | hotelclub.com | cheaptickets.com | ratestogo.com | asiahotels.com

 

Вложения

Re: psql dynamic comments

От
Fabrízio de Royes Mello
Дата:


2010/10/6 Little, Douglas <DOUGLAS.LITTLE@orbitz.com>

 

 

Unfortunately the variable doesn’t get replaced due to the quotes.

COMMENT ON INDEX mdm_mart_tbls.mdm_gotoastcampaignevt_pk IS 'created by dwda-1618 on :currtime';

 

I’ve tried various options,  2,3,4 quotes.  Concatenation, Building the entire string as the variable.  But nothing seems to work.

 

Any suggestions?

 



Try this:


postgres@bdteste=# \set message ''''`echo 'Created by Fabrizio on '``date '+20%y-%m-%d %H:%M:%S'`''''
postgres@bdteste=# comment on table city is :message;
COMMENT
postgres@bdteste=# \dt+ city
                                      Lista de relações
 Esquema | Nome |  Tipo  |   Dono   |  Tamanho   |                 Descrição                  
---------+------+--------+----------+------------+--------------------------------------------
 public  | city | tabela | postgres | 8192 bytes | Created by Fabrizio on 2010-10-06 12:39:04
(1 linha)


--
Fabrízio de Royes Mello
>> Blog sobre TI: http://fabriziomello.blogspot.com