Re: [SQL] Is this possible?

2009-02-17 Thread Scott Marlowe
On Mon, Feb 16, 2009 at 7:36 PM, johnf jfabi...@yolo.com 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

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 But there may or may

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: 0x3FFF606C,

[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

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) overview=

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

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
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)