Re: need to join successive log entries into one - Mailing list pgsql-sql

From Oliver Elphick
Subject Re: need to join successive log entries into one
Date
Msg-id 200103142107.f2EL7ZG21981@linda.lfix.co.uk
Whole thread Raw
In response to need to join successive log entries into one  (George Young <gry@ll.mit.edu>)
List pgsql-sql
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'snot 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,
andglorify your Father which is in      heaven."         Matthew 5:16 
 




pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: FETCH ... INTO in PL/pgSQL
Next
From: Richard H
Date:
Subject: Re: PL/pgSQL "compilation error"