Re: CONCAT function

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Marek Lewczuk <newsy(at)lewczuk(dot)com>
Cc: Lista dyskusyjna pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CONCAT function
Date: 2003-09-16 14:24:18
Message-ID: Pine.LNX.4.33.0309160819380.4190-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 16 Sep 2003, scott.marlowe wrote:

> On Tue, 16 Sep 2003, Marek Lewczuk wrote:
>
> > Hello,
> > As I'm in the middle of the migration process form mysql to pg I found
> > that there is no CONCAT function which is available in mysql. Can
> > anybody tell me how to implement this function using plPERL or plPGSQL
> > language ?
>
> What's wrong with using the SQL spec || operator?

Having read the other bits of this thread now, it seems you'd like to
create a simple function (pl/sql is good enough to so it, no need for
pl/pgsql or what) to do this, but it needs to handle a variable number of
args.

While pgsql doesn't, to the best of my knowledge, support variable number
of arguments, it DOES support overloading. So, you can always create a
series of functions that hand 2, 3, 4, 5, 6, etc.., arguments until you
get enough to handle all the situations you need.

I still stand by my recommendation to start MySQL with the ansi
compatibility switch and use the SQL standard specified || operator for
portability, as the next database you want to port to after Postgresql may
not be flexible enough to do this.

Standards are nice, they improve portability, and while the default
behaviour of MySQL here is not spec, at least they do provide a switch to
make it work the right way.

Of course, if you've got other packaged apps using || as the OR operator,
you might have issues there. But, if the statements of MySQL are to be
taken seriously, i have the feeling that one day || may well be deprecated
as they try to get their database server more and more accepted for the
server room as a replacement for other databases, so you might as well be
ahead of the curve, and not caught by surprise when that happens.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-16 14:36:22 Re: update field using substrings of another field
Previous Message Kaare Rasmussen 2003-09-16 14:18:55 Re: State of Beta 2