[GRLUG] Postgresql help

David Hoppe dave at hopasaurus.com
Tue Apr 12 14:35:34 EDT 2011


Is there a really good reason for having each day in a separate table?  
If not put all the data in a single table with a field for the date and 
your query turns into "select * form tnt_audi.summaryreport_login_stats 
where datefield*=(CURRENT_DATE)"

*datefield is whatever the date field becomes.

If there is a really good reason I would be happy to try harder but 
would like to know that there really is a reason.



David Hoppe



On 4/12/2011 2:10 PM, Richard Maloley II 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 
> <mailto:richard at rrcomputerconsulting.com>
> w: http://www.rrcomputerconsulting.com
>
>
>
> -- 
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.
>
>
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shinobu.grlug.org/pipermail/grlug/attachments/20110412/a6e4b538/attachment.html>


More information about the grlug mailing list