sql and timestamp variable - Mailing list pgsql-general

From Johnson, Shaunn
Subject sql and timestamp variable
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB05FED2ED@snt452.corp.bcbsm.com
Whole thread Raw
Responses Re: sql and timestamp variable  (Richard Huxton <dev@archonet.com>)
Re: sql and timestamp variable  (nolan@celery.tssi.com)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql and bytea
Next
From: "scott.marlowe"
Date:
Subject: Re: TESTING the DATABASE