Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Andreas
string_replace would only replace one searchstring at a time. In this case I need to replace 3 : (0) ( ) because there could be some braces not just as (0) since the innermost replace spares braces regardless where they are. Could one express the following in one expression 1) remo

Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Raj Mathur
On Tuesday 17 Feb 2009, Andreas wrote: > [snip] > case > when regexp_replace(p, E'[^0-9+]', '', 'g') ~ E'^(\\+|00)49' > then '0'|| >regexp_replace( > regexp_replace( > regexp_replace(p, E'[^0-9+()]', '', 'g') > , '\\(0\\)||\\(||\\)', '', 'g') >

Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Andreas
Hi Thanks, that really works :) Now a last extension. Some numbers were entered in a "110% perfect" way with an excessive (0). +49 (0) 123 / 456 789 I have to suspect the source liked to express that it's either +49 or 0 if the +49 isn't applicable, but not both. Both together are semantic

Re: [SQL] How to find number of seconds between 2 timestamps

2009-02-17 Thread Richard Huxton
Woody Woodring wrote: > I am trying to calculate a rate per second and am having trouble getting the > number of seconds between the two timestamps to use in the formula. > > overview=> select extract(epoch from interval '1 day'::interval); > date_part > --- > 86400 > (1 row) > >

[SQL] How to find number of seconds between 2 timestamps

2009-02-17 Thread Woody Woodring
I am trying to calculate a rate per second and am having trouble getting the number of seconds between the two timestamps to use in the formula. overview=> select extract(epoch from interval '1 day'::interval); date_part --- 86400 (1 row) overview=> select extract(epoch from inter

Re: [SQL] Is this possible?

2009-02-17 Thread A. Kretschmer
In response to johnf : > Wow that looks like it will work - thanks. > When you say 'within a transaction' do you mean starting with > "Begin" and using "commit"? Exactly. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF60

Re: [SQL] Is this possible?

2009-02-17 Thread johnf
On Monday 16 February 2009 10:32:26 pm A. Kretschmer wrote: > In response to johnf : > > Hi, > > I'm not to sure this is possible. > > > > I need to replace a primary key (pkid) with the value of a different > > field. I have > > pkid = 200 > > attendid = 301 > > > > I need the pkid = 301 > > > > B

[SQL] Stored Procedure Generator?

2009-02-17 Thread Steve Nyemba
Hi, I have written a stored procedure generator in PgSQL that will generate stored procedures around a table to perform: Insert; update; retrieve all; retrieve by primary key. I would like to know if there is use for such a utility and/or if I am re-inventing the wheel? Also if there is a use for s

Re: [SQL] Is this possible?

2009-02-17 Thread Scott Marlowe
On Mon, Feb 16, 2009 at 7:36 PM, johnf wrote: > Hi, > I'm not to sure this is possible. > > I need to replace a primary key (pkid) with the value of a different field. > I have > pkid = 200 > attendid = 301 > > I need the pkid = 301 > > But there may or may not be a pkid that already exist that ha