Search Postgresql Archives

Re: || versus concat( ), diff behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mar 2, 2012, at 12:58 PM, <david.sahagian@xxxxxxx> 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 restriction of 10 characters in the first place? Perhaps the type text is what you're really after?


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux