pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
String concat operator???
4+ messages / 4 participants
[nested] [flat]

* String concat operator???
@ 1999-06-30 13:16  webmaster <webmaster@tony.cz>
  0 siblings, 2 replies; 4+ messages in thread

From: webmaster @ 1999-06-30 13:16 UTC (permalink / raw)
  To: pgsql-sql

I'm trying to update a character field by foll. query:

update temp_kat set id_look = substr(ident,1,6) || '-' || substr(ident,7,7)
where from_kat='P'; 

Both id_look and ident are varchars.. So what's wrong with || operator? There
is an error parsing the querry near || ...

Who is stupid? Me, or postgresql 6.4.2 :) ? It look like legal expression for
me...
--

Michal Samek, Tony distribuce s.r.o.
webmaster@tony.cz  (++420659/321350)
ICQ: 38607210



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] String concat operator???
@ 1999-06-30 13:35  Herouth Maoz <herouth@oumail.openu.ac.il>
  parent: webmaster <webmaster@tony.cz>
  1 sibling, 1 reply; 4+ messages in thread

From: Herouth Maoz @ 1999-06-30 13:35 UTC (permalink / raw)
  To: webmaster@tony.cz; pgsql-sql

At 16:16 +0300 on 30/06/1999, webmaster wrote:


> Both id_look and ident are varchars.. So what's wrong with || operator? There
> is an error parsing the querry near || ...
>
> Who is stupid? Me, or postgresql 6.4.2 :) ? It look like legal expression for
> me...

Old problem... "||" doesn't have associativity, so when you use a||b||c, it
gets mixed up. Solution - use (a||b) || c. Preferably ((a||b)||c).

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] String concat operator???
@ 1999-06-30 14:18  Tom Lane <tgl@sss.pgh.pa.us>
  parent: webmaster <webmaster@tony.cz>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 1999-06-30 14:18 UTC (permalink / raw)
  To: webmaster@tony.cz; +Cc: pgsql-sql

webmaster <webmaster@tony.cz> writes:
> update temp_kat set id_look = substr(ident,1,6) || '-' || substr(ident,7,7)
> where from_kat='P'; 

> Both id_look and ident are varchars.. So what's wrong with || operator? There
> is an error parsing the querry near || ...

In 6.4.* you have to parenthesize the above because Postgres doesn't
assume that the operator || is associative:

update temp_kat set id_look = (substr(ident,1,6) || '-') || substr(ident,7,7)
where from_kat='P'; 

6.5 takes the query without parentheses...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] String concat operator???
@ 1999-07-01 03:41  Bruce Momjian <maillist@candle.pha.pa.us>
  parent: Herouth Maoz <herouth@oumail.openu.ac.il>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 1999-07-01 03:41 UTC (permalink / raw)
  To: Herouth Maoz <herouth@oumail.openu.ac.il>; +Cc: webmaster@tony.cz; pgsql-sql

> At 16:16 +0300 on 30/06/1999, webmaster wrote:
> 
> 
> > Both id_look and ident are varchars.. So what's wrong with || operator? There
> > is an error parsing the querry near || ...
> >
> > Who is stupid? Me, or postgresql 6.4.2 :) ? It look like legal expression for
> > me...
> 
> Old problem... "||" doesn't have associativity, so when you use a||b||c, it
> gets mixed up. Solution - use (a||b) || c. Preferably ((a||b)||c).

And fixed in 6.5.


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-07-01 03:41 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-30 13:16 String concat operator??? webmaster <webmaster@tony.cz>
1999-06-30 13:35 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-07-01 03:41   ` Bruce Momjian <maillist@candle.pha.pa.us>
1999-06-30 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>

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