From: | nolan(at)celery(dot)tssi(dot)com |
---|---|
To: | SJohnson6(at)bcbsm(dot)com (Johnson, Shaunn) |
Cc: | pgsql-general(at)postgresql(dot)org (\"pg-general E-mail\") |
Subject: | Re: sql and timestamp variable |
Date: | 2003-05-15 16:55:43 |
Message-ID: | 20030515165543.4064.qmail@celery.tssi.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Nigel J. Andrews | 2003-05-15 17:08:10 | Re: - what protocol for an Internet postgres |
Previous Message | Fernando Papa | 2003-05-15 16:22:29 | Declaring cursors in pl/pgsql and using with FOR/LOOP |