> 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