Re: sql and timestamp variable

Поиск
Список
Период
Сортировка
От nolan@celery.tssi.com
Тема Re: sql and timestamp variable
Дата
Msg-id 20030515165543.4064.qmail@celery.tssi.com
обсуждение исходный текст
Ответ на sql and timestamp variable  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Список pgsql-general
> select count(*) from  db2_ps_regprof_$datemonth where mbr is null ;
>
> [/snip wishful thinking]
>
> How can you do this?  Otherwise, I may have to do this in Perl,
> perhaps?

Try this in psql:

\set datemonth xxxxxxx  (fill in whatever you need here)

select count(*) from db2_ps_regprof_:datemonth where mbr is null;

Is that what you're after?

You could even pre-load some values via the .psqlrc file (and update
that file with a cron job as needed) to pre-load some values:

select count(*) from db2_ps_regprof_:current where mbr is null;
select count(*) from db2_ps_regprof_:last where mbr is null;
etc.

There's some stuff in the psql documentation about % and backticks, but
that appears to only work with prompts.  What would be nice would be if the
text in backticks could also be executed and the results fed into a
set command, so that you could do the following:

\set datemonth `select table_name from table_select where month = 'Jan';`
--
Mike Nolan

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

Предыдущее
От: "Fernando Papa"
Дата:
Сообщение: Declaring cursors in pl/pgsql and using with FOR/LOOP
Следующее
От: "Nigel J. Andrews"
Дата:
Сообщение: Re: - what protocol for an Internet postgres