Thread: Comments on tables

Comments on tables

From
pasman pasmański
Date:
Hello.


How to add comment on table with calculated value ?

COMMENT ON TABLE test IS 'Updated ' || current_date;

not works ...

Regards.

------------
pasman

Re: Comments on tables

From
Szymon Guz
Date:
2010/11/10 pasman pasmański <pasman.p@gmail.com>
Hello.


How to add comment on table with calculated value ?

COMMENT ON TABLE test IS 'Updated ' || current_date;

not works ...


Hi,
I'd suggest something like this:

do $$
begin
  execute 'COMMENT ON TABLE test_count is ''Updated ' || current_date || '''';
end$$; 

This would run on postgres from 9.0, for earlier versions, you could always write similar function.


regards
Szymon

Re: Comments on tables

From
Vibhor Kumar
Date:
On Nov 10, 2010, at 2:55 PM, pasman pasmański wrote:

> How to add comment on table with calculated value ?
>
> COMMENT ON TABLE test IS 'Updated ' || current_date;


You can create function to do that.

Or

If you are using PG9.0, then DO would help you, as given below:
do $$
Declare
t text;
begin
t:='COMMENT ON TABLE TEST_COPY IS '||''''||'TEST WITH '||current_date||'''';
execute t;
end;
$$ language plpgsql;

Thanks & Regards,
Vibhor Kumar



Re: Comments on tables

From
Pasman
Date:
> do $$
> begin
>   execute 'COMMENT ON TABLE test_count is ''Updated ' || current_date ||
> '''';
> end$$;
>

thanks, it works cool.


pasman