Re: || versus concat( ), diff behavior - Mailing list pgsql-general

From Ben Chobot
Subject Re: || versus concat( ), diff behavior
Date
Msg-id A042A0C8-7BE2-4E0D-B71F-F221626D6614@silentmedia.com
Whole thread Raw
In response to || versus concat( ), diff behavior  (<david.sahagian@emc.com>)
List pgsql-general
On Mar 2, 2012, at 12:58 PM, <david.sahagian@emc.com> wrote:

> Can anybody please point me to where this "difference of behavior" is explained/documented ?
> Thanks,
> -dvs-
>
> -- version = 9.1.3
> do $$
> declare
>  v_str  char(10);
> begin
>  v_str := 'abc' ;
>  raise info '%', concat(v_str, v_str) ;
>  raise info '%', v_str||v_str ;
> end
> $$;
>
> INFO:  abc       abc
> INFO:  abcabc

I'm not sure why || works differently than concat(), but char() is whitespace-padded. You told the db you wanted "10
characters",so that's what it gave you. Perhaps you wanted vchar(10)? For that matter, do you even want that
restrictionof 10 characters in the first place? Perhaps the type text is what you're really after? 


pgsql-general by date:

Previous
From:
Date:
Subject: || versus concat( ), diff behavior
Next
From: Philip Couling
Date:
Subject: Re: || versus concat( ), diff behavior