sql and timestamp variable

Поиск
Список
Период
Сортировка
От Johnson, Shaunn
Тема sql and timestamp variable
Дата
Msg-id 73309C2FDD95D11192E60008C7B1D5BB05FED2ED@snt452.corp.bcbsm.com
обсуждение исходный текст
Ответы Re: sql and timestamp variable  (Richard Huxton <dev@archonet.com>)
Re: sql and timestamp variable  (nolan@celery.tssi.com)
Список pgsql-general

Howdy:

I have a query where I hardcode (and manually change)
a table name that has the date as part of it's name.

[snip examples]

select count(*) from  db2_ps_regprof_200304 where mbr is null;

--

update db2_ps_fac_up200304
set mbr=mbr_num
from t_pos_mbr
where
contract_num = contract and
sex_code = sex and
birth_year_num = byr and
birth_mt_num = bmm and
birth_day_num=bday and
substr(patient_first_name,1,1) = substr(mbrfirst,1,1)

[/snip examples]

The tables will change every month, so, where this month
the table name is <blah-blah-blah_200304> , will be
<blah-blah-blah_200305> next month. 

I don't want to totally change the process; I want to know if
it's possible to create some variable and have it
attached to the name of the tables so it will know
exactly which one to modify.

Something like

[snip wishful thinking]

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?

Thanks!

-X

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: psql and bytea
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: TESTING the DATABASE