Re: [SQL] String concat operator??? - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] String concat operator???
Date
Msg-id 21995.930752286@sss.pgh.pa.us
Whole thread Raw
In response to String concat operator???  (webmaster <webmaster@tony.cz>)
List 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


pgsql-sql by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: [SQL] String concat operator???
Next
From: Tom Lane
Date:
Subject: Re: [SQL] More fun with random selects