Thread: concatenation of string literals

concatenation of string literals

From
Kurt Seel
Date:
This works :
psql -c "select arcode ||  phnum from nccbor_member;"

 But this doesn't
psql -c " select arcode || '-' || phnum from nccbor_member;"

 It's an inconvience because I am doing mail merges in wordperfect
using postodbc, and I keep having to do things like put dashes in
phone numbers and such in wordperfect, is there another way to concat
string literals?

--
Kurt Seel, Systems Engineer
Unified Technologies Corp.
Phone : 610 964 8200
Email : kseel@ut{anti-spam]corp.com

 To send me email, remove the {anti-spam] from the above address.

Re: [GENERAL] concatenation of string literals

From
eric@gateway.ctlno.com
Date:

On Fri, 17 Jul 1998, Kurt Seel wrote:

> This works :
> psql -c "select arcode ||  phnum from nccbor_member;"
>
>  But this doesn't
> psql -c " select arcode || '-' || phnum from nccbor_member;"
>
>  It's an inconvience because I am doing mail merges in wordperfect
> using postodbc, and I keep having to do things like put dashes in
> phone numbers and such in wordperfect, is there another way to concat
> string
literals?
>
> --
> Kurt Seel, Systems Engineer
> Unified Technologies Corp.
> Phone : 610 964 8200
> Email : kseel@ut{anti-spam]corp.com
>
>  To send me email, remove the {anti-spam] from the above address.
>

You will probably need to put parenthases around either the first two or
the last two strings:

psql -c " select (arcode || '-') || phnum from nccbor_member;"

that should work fine


Re: [GENERAL] concatenation of string literals

From
Maarten Boekhold
Date:
> > This works :
> > psql -c "select arcode ||  phnum from nccbor_member;"
> >
> >  But this doesn't
> > psql -c " select arcode || '-' || phnum from nccbor_member;"
> >
> >  It's an inconvience because I am doing mail merges in wordperfect
> > using postodbc, and I keep having to do things like put dashes in
> > phone numbers and such in wordperfect, is there another way to concat
> > string
> literals?
> >
> > --
> > Kurt Seel, Systems Engineer
> > Unified Technologies Corp.
> > Phone : 610 964 8200
> > Email : kseel@ut{anti-spam]corp.com
> >
> >  To send me email, remove the {anti-spam] from the above address.
> >
>
> You will probably need to put parenthases around either the first two or
> the last two strings:
>
> psql -c " select (arcode || '-') || phnum from nccbor_member;"
>
> that should work fine

My guess is you have to cast the '-' to text and that postgresql at the
moment sees '-' as a char:

select arcode || '-'::text || phnum from nccbor_members

Maarten

_____________________________________________________________________________
| TU Delft, The Netherlands, Faculty of Information Technology and Systems  |
|                   Department of Electrical Engineering                    |
|           Computer Architecture and Digital Technique section             |
|                          M.Boekhold@et.tudelft.nl                         |
-----------------------------------------------------------------------------


Re: [GENERAL] concatenation of string literals

From
Guido Piazzi
Date:
On Fri, 17 Jul 1998, Kurt Seel wrote:

> This works :
> psql -c "select arcode ||  phnum from nccbor_member;"
>
>  But this doesn't
> psql -c " select arcode || '-' || phnum from nccbor_member;"

Try:
psql -c " select (arcode || '-') || phnum from nccbor_member;"

Regards,
------------------------------------------------------------------------
// Guido Carlo Piazzi                       Accompagnatore naturalistico
// gpiazzi@nemo.it            Visitate il sito WWW.ParcoDelTicino.Pmn.It
------------------------------------------------------------------------