[GRLUG] Postgresql help

Roger Roelofs roger.roelofs at gmail.com
Tue Apr 12 14:23:41 EDT 2011


Richard,

Is this a stored proc?  We hormally handle stuff like this by
dynamically constructing the sql in php.

On Tue, Apr 12, 2011 at 2:10 PM, Richard Maloley II
<richard at rrcomputerconsulting.com> wrote:
> Hello,
> I'm trying to create a really simple query against a Postgresql database.
> This database creates a new table every single day for daily statistics,
> therefore all tables are named the same except for the different date
> appended to the name.
> My query right now is simple: Execute a single SQL statement that will
> gather data from the correct daily table depending on the day. For example:
> SELECT * FROM tnt_audit.summaryreport_login_stats_20110412;
> The above query will select all of the data for today. The date piece,
> 20110412, needs to be dynamically changed. Here is what I thought of:
> SELECT
> *
> FROM
> tnt_audit.summaryreport_login_stats_(CURRENT_DATE)
> ;
> However this results in the following error message:
> ERROR:  function tnt_audit.summaryreport_login_stats_(date) does not exist
> LINE 4:  tnt_audit.summaryreport_login_stats_(CURRENT_DATE)
>          ^
> HINT:  No function matches the given name and argument types. You might need
> to add explicit type casts.
> ********** Error **********
> ERROR: function tnt_audit.summaryreport_login_stats_(date) does not exist
> SQL state: 42883
> Hint: No function matches the given name and argument types. You might need
> to add explicit type casts.
> Character: 17
> I'm no SQL expert and I've been unable to find any direction on how to
> accomplish this. I feel as though it should be simple to append this data to
> the table name but the answer eludes me. For reference we are using version
> 8.x of the database.
> Thanks,
> Richard Maloley II
> Rick and Richard Computer Consulting
> p: 616-745-6914
> e: richard at rrcomputerconsulting.com
> w: http://www.rrcomputerconsulting.com
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
>



-- 
Roger

Roger Roelofs
Know what you value.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the grlug mailing list