Fwd: [SQL] replace text occurrences loaded from table

2012-10-30 Thread jan zimmek
thanks igor, the combination of regexp_replace and string_agg works great for me. the query runs a lot faster than my previous solution and is way easier to grasp. Anfang der weitergeleiteten Nachricht: > Von: Igor Romanchenko > Betreff: Aw: [SQL] replace text occurrences loaded from

Re: [SQL] replace text occurrences loaded from table

2012-10-30 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of jan zimmek > Sent: Tuesday, October 30, 2012 7:45 AM > To: pgsql-sql@postgresql.org > Subject: [SQL] replace text occurrences loaded from table > > h

[SQL] replace text occurrences loaded from table

2012-10-30 Thread jan zimmek
hello, i am actually trying to replace all occurences in a text column with some value, but the occurrences to replace are defined in a table. this is a simplified version of my schema: create temporary table tmp_vars as select var from (values('ABC'),('XYZ'),('VAR123')) entries (var); create

Re: [SQL] replace " with nothing

2011-05-12 Thread Lew
Tony Capobianco wrote: We are converting from Oracle to Postgres. An Oracle script contains this line: select replace(firstname,'"'), memberid, emailaddress from members; in an effort to replace the " with nothing. How can I achieve the same result with Postgres? Here's the Postgres error

Re: [SQL] replace " with nothing

2011-05-11 Thread Leif Biberg Kristensen
On Wednesday 11 May 2011 23:25:34 Ross J. Reedstrom wrote: > On Wed, May 11, 2011 at 11:11:07PM +0200, Leif Biberg Kristensen wrote: > > although it's a little above me why you would want to select firstname in > > the first place when you proceed to replace it with nothing. > > Nah, he's replacin

Re: [SQL] replace " with nothing

2011-05-11 Thread Ross J. Reedstrom
On Wed, May 11, 2011 at 11:11:07PM +0200, Leif Biberg Kristensen wrote: > > although it's a little above me why you would want to select firstname in the > first place when you proceed to replace it with nothing. Nah, he's replacing double-quote-character " with nothing. An attempt to protect a

Re: [SQL] replace " with nothing

2011-05-11 Thread Ross J. Reedstrom
On Wed, May 11, 2011 at 04:51:05PM -0400, Tony Capobianco wrote: > Ok, I think I found it: > > select translate(firstname,'"','') from members; > > gives me what I want. Yup, you beat me to the answer. For the archives, if this was a compatability question (for example, you've got framework code

Re: [SQL] replace " with nothing

2011-05-11 Thread Leif Biberg Kristensen
On Wednesday 11 May 2011 22:29:40 Tony Capobianco wrote: > We are converting from Oracle to Postgres. An Oracle script contains > this line: > > select replace(firstname,'"'), memberid, emailaddress from members; > > in an effort to replace the " with nothing. How can I achieve the same > resu

Re: [SQL] replace " with nothing

2011-05-11 Thread Tony Capobianco
Ok, I think I found it: select translate(firstname,'"','') from members; gives me what I want. Thanks. On Wed, 2011-05-11 at 16:29 -0400, Tony Capobianco wrote: > We are converting from Oracle to Postgres. An Oracle script contains > this line: > > select replace(firstname,'"'), memberid, em

[SQL] replace " with nothing

2011-05-11 Thread Tony Capobianco
We are converting from Oracle to Postgres. An Oracle script contains this line: select replace(firstname,'"'), memberid, emailaddress from members; in an effort to replace the " with nothing. How can I achieve the same result with Postgres? Here's the Postgres error I get: select replace(fir

[SQL] Replace usage of a table in query with its array values

2007-07-02 Thread Loredana Curugiu
Hi everybody, I have the following 3 tables: sent_messages uid | receiver| theme| date -+--+-+--- 1 | +40741775630 | CAND1 | 2007-06-12 14:06:57.843024+00 2 | +40741775630 | MAMA | 2007-06-12 14:07:

Re: [SQL] Replace string

2007-04-12 Thread PostgreSQL Admin
test=*# select regexp_replace(regexp_replace('The blue fox\'s fur.', ' ', '-', 'g'), '\\.', ''); regexp_replace The-blue-fox's-fur (1 row) Andreas Thanks for the input. I came up with this: REPLACE(regexp_replace('The blue fox\'s fur', '[[:punct:]]', ''), ' ',

[SQL] replace EXCEPT by JOIN

2007-04-12 Thread T E Schmitz
The following construct does what I need but is there a better way of expressing this? select * from ( SELECT DISTINCT section.section_pk FROM ITEM LEFT JOIN product product ON Item.product_fk = product.product_pk LEFT JOIN section section ON product.section_fk = section.section_pk WHERE i

Re: [SQL] Replace string

2007-04-11 Thread Rodrigo De León
On 4/10/07, PostgreSQL Admin <[EMAIL PROTECTED]> wrote: Hi, I want to replace a title with dashes and also remove punctuation. e.g, The blue fox's fur. -> The-blue-fox-fur Thanks for any input, J SELECT translate('The blue fox''s fur.', ' .''', '-') ---(end of broa

Re: [SQL] Replace string

2007-04-11 Thread A. Kretschmer
am Tue, dem 10.04.2007, um 16:40:41 -0400 mailte PostgreSQL Admin folgendes: > Hi, > > I want to replace a title with dashes and also remove punctuation. > > e.g, The blue fox's fur. -> The-blue-fox-fur test=*# select regexp_replace(regexp_replace('The blue fox\'s fur.', ' ', '-', 'g'), '\\.

[SQL] Replace string

2007-04-11 Thread PostgreSQL Admin
Hi, I want to replace a title with dashes and also remove punctuation. e.g, The blue fox's fur. -> The-blue-fox-fur Thanks for any input, J ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate su

Re: [SQL] Replace function ...

2004-05-21 Thread Kornelije Rabuzin
thanks If I don't find some other solution, I'll do it . so, thanks ... best regards Kornelije On Wed, 19 May 2004, BenLaKnet wrote: > I try to reencode postgresql db ... all is running ... in your shell : > > - pg_dump db -f fileout > > - iconv fileout i do not remember paramete

Re: [SQL] Replace function ...

2004-05-21 Thread Kornelije Rabuzin
Thank you very much, but the database I'm using is not mine that's why I cannot change anything If I wont manage to write this replace function, I'll probably use this solution ... so thank you best regards R. K. On Wed, 19 May 2004, [ISO-8859-1] Benoît BOURNON wrote: > I try to r

Re: [SQL] Replace function ...

2004-05-20 Thread Benoît BOURNON
I try to reencode postgresql db ... all is running ... in your shell : - pg_dump db  -f fileout - iconv fileout i do not remember parameters but iconv converts the file. - createdb db -U unicode (for example) - pgsql db < fileout_converted We change previous year the encoding of this webs

Re: [SQL] Replace function ...

2004-05-17 Thread Yasir Malik
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > I need to write a function which has to replace a character with two or three other > characters > You can use the replace function as specified below: replace(string text, from text, to text) text Replace all occurrences in @string of substr

[SQL] Replace function ...

2004-05-17 Thread Kornelije
Hi,   I need to write a function which has to replace a character with two or three other characters   I have some data in the DB and when I retrieve this data, I have sorting problems because I use specific Croatian characters I know that the DB is not setup properly, but I cannot

[SQL] REPLACE

2004-02-01 Thread LawyerKill
LK I'm using Foxpro 8 and I'm trying to merge selective data from 4 different tables into a new table.The problem is that the tables are not alike, Table one may have 4 records with the name John in them, table 2 had only one John with one account # in that record, so I want to have a new table wi

Re: [SQL] replace null with 0 in subselect ?

2002-10-16 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > Coalesce((select max(pos)+1 from tab2), 0) > should work. Small comment: it's probably noticeably faster to do (select Coalesce(max(pos), 0) +1 from tab2) I think that the former will result in two evaluations of the sub-select in the typical c

Re: [SQL] replace null with 0 in subselect ?

2002-10-16 Thread Stephan Szabo
On Wed, 16 Oct 2002, Albrecht Berger wrote: > Hello, > I have a statement like this : > > INSERT INTO tab1 (c1, c2, c3) VALUES (1,2, SELECT MAX(pos)+1 FROM tab2); Coalesce is your friend. :) Coalesce((select max(pos)+1 from tab2), 0) should work. ---(end of broadcast)

Re: [SQL] replace null with 0 in subselect ?

2002-10-16 Thread Ian Barwick
On Wednesday 16 October 2002 12:07, Albrecht Berger wrote: > Hello, > I have a statement like this : > > INSERT INTO tab1 (c1, c2, c3) VALUES (1,2, SELECT MAX(pos)+1 FROM tab2); > > This works fine if the subselect returns a value, but if it returns > null there is a problem. In this case a 0 has

[SQL] replace null with 0 in subselect ?

2002-10-16 Thread Albrecht Berger
Hello, I have a statement like this : INSERT INTO tab1 (c1, c2, c3) VALUES (1,2, SELECT MAX(pos)+1 FROM tab2); This works fine if the subselect returns a value, but if it returns null there is a problem. In this case a 0 has to be inserted. Is there any pg function which solves this problem ? I

Re: [SQL] Replace into...?

2001-03-27 Thread Tom Lane
"Diehl, Jeffrey" <[EMAIL PROTECTED]> writes: > I'm in the process of migrating a database and application suite from mysql > to postgresql. The problem is that I've used > mysql's "replace into..." quite frequently... > Does anyone know of a "clean" way to implement this feature in postgresql? >

Re: [SQL] Replace into...?

2001-03-27 Thread Peter Eisentraut
Diehl, Jeffrey writes: > I'm in the process of migrating a database and application suite from mysql > to postgresql. The problem is that I've used > mysql's "replace into..." quite frequently... begin transaction; update ... insert ... commit; or some permutation thereof. If you need to

Re: [SQL] replace??

2000-12-19 Thread Brett W. McCoy
On Tue, 19 Dec 2000, Bruno Boettcher wrote: > actually i look up if the corresponding entry exists (comparing > user-name and field-name) if yes i update, if no i insert > > this isn't very appealing, but i couldn't find another way yet to make > this shorter... > > would be nice if something

[SQL] replace??

2000-12-19 Thread Bruno Boettcher
hello, i have the following problem: i have in php an array structure with user-prefs that have to be stored onto DB actually i look up if the corresponding entry exists (comparing user-name and field-name) if yes i update, if no i insert this isn't very appealing, but i couldn't find a