sql and timestamp variable

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: "pg-general (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: sql and timestamp variable
Date: 2003-05-15 14:54:01
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB05FED2ED@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guy Fraser 2003-05-15 15:24:00 How do I view the logs?
Previous Message Tom Lane 2003-05-15 14:47:53 Re: psql and bytea