Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id B21849FB75F for ; Thu, 28 Jun 2007 12:08:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 62005-09 for ; Thu, 28 Jun 2007 12:08:02 -0300 (ADT) X-Greylist: delayed 00:21:45.052436 by SQLgrey-1.7.4 Received: from spoetnik.xs4all.nl (spoetnik.xs4all.nl [82.95.228.65]) by postgresql.org (Postfix) with ESMTP id 7BDCB9FB454 for ; Thu, 28 Jun 2007 12:08:02 -0300 (ADT) Received: by spoetnik.xs4all.nl (Postfix, from userid 1000) id 92A061CC91; Thu, 28 Jun 2007 16:46:15 +0200 (CEST) Date: Thu, 28 Jun 2007 16:46:15 +0200 From: Reinoud van Leeuwen To: pgsql-sql@postgresql.org Subject: record fields as columns in reports Message-ID: <20070628144615.GQ72343@spoetnik.xs4all.nl> Mail-Followup-To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-message-flag: Warning! The sender of this mail thinks you should use a more secure email client. User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/234 X-Sequence-Number: 28724 Hi everybody, I have a script that runs every night and produces a list of a few error conditions and the number. My manager would like it in a form where he can produce some charts in a spreadsheet (that's probably why he's a manager ";-). So the table I store the errormessages in has a format like this: CREATE TABLE repport_history ( rundate date, errordescription character varying(255), number bigint ) And I would like an output with something like: 06/22 06/23 06/24 06/25 ERROR1 10 10 9 8 ERROR2 250 300 220 200 ERROR3 4 2 0 0 (probably in csv or something like that but that is the easy part ";-) The problems are: - how to create a dynamic result type? (is that possible in a stored procedure?) - how to make sure that missing records are reported as 0 (some errors might not have entries on some dates) Has somebody ever made a generic solution for something like this? (or do I need a reporting tool?) Thanks in advance, Reinoud -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud.v@n.leeuwen.net http://www.xs4all.nl/~reinoud __________________________________________________