pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: George Young <gry@ll.mit.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: need to join successive log entries into one
Date: Wed, 14 Mar 2001 21:07:35 +0000
Message-ID: <200103142107.f2EL7ZG21981@linda.lfix.co.uk> (raw)
In-Reply-To: <gry@ll.mit.edu> <01031413092300.02477@pen>

George Young wrote:
...
  >I need to produce a new table that coalesces immediately successive
  >operations on a run into one, e.g.:
  >
  >run   |  start               | done
  >  1415|  2001-01-29 12:36:55| 2001-02-07 13:02:38
  >  1415|  2001-02-14 07:40:04|
  >  1747|  2001-02-15 09:14:39| 2001-03-01 09:02:39
  >  1747|  2001-03-05 13:13:58|  
  >  1954|  2001-02-02 20:55:39| 2001-03-02 10:17:15
  >
  >i.e. where a run has one or more steps with succesive seq values,
  >or equivalently, with abutting start/end values, then I want
  >the new table to have only one entry representing the full span of
  >time.  Null 'done' just means it's not done yet.  
...
  >Can anyone think of a way I can do this in postgres?
 
I think you would be better off feeding the log out of the database into
a perl script.  SQL is a set-oriented language that can't do this
sort of thing without some appalling contortions, if at all.  (I can't
think of a way to do it.) So, store the data in PostgreSQL, but do
procedural processing in a more appropriate language.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Let your light so shine before men, that they may see 
      your good works, and glorify your Father which is in 
      heaven."         Matthew 5:16 





view thread (6+ messages)  latest in thread

Message-ID: <200103142107.f2EL7ZG21981@linda.lfix.co.uk>
Permalink:  ../200103142107.f2EL7ZG21981@linda.lfix.co.uk/
Also on:    postgresql.org/message-id/200103142107.f2EL7ZG21981@linda.lfix.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: olly@lfix.co.uk, gry@ll.mit.edu
  Subject: Re: need to join successive log entries into one
  In-Reply-To: <200103142107.f2EL7ZG21981@linda.lfix.co.uk>
  References: <200103142107.f2EL7ZG21981@linda.lfix.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox