Re: manipulate and return row inside a function

From: Claudio Poli <masterkain(at)gmail(dot)com>
To: pgsql novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: manipulate and return row inside a function
Date: 2013-11-14 13:13:15
Message-ID: CANp6Qo+XW=9u7LE4aMCT+yhOLyWxBv8ZU0bBg6T2HxPT_T0n2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I solved it with using COALESCE.

Best,
c.

On Thu, Nov 14, 2013 at 9:03 AM, Luca Ferrari <fluca1978(at)infinito(dot)it> wrote:

> On Thu, Nov 14, 2013 at 8:50 AM, Claudio Poli <masterkain(at)gmail(dot)com>
> wrote:
> > some other things I'm trying:
> >
> > SELECT
> > pick_artist(album_artist, artist) AS artist,
> >
> >
> >
> > CREATE OR REPLACE FUNCTION pick_artist(album_artist varchar,
> album
> > varchar)
> > RETURNS varchar AS $$
> > BEGIN
> > IF album_artist IS NULL THEN RETURN album;
> > ELSIF album_artist = '' THEN RETURN album;
> > ELSE RETURN album_artist;
> > END IF;
> > END;
> > $$ LANGUAGE plpgsql;
> >
> >
>
> This works fine for me:
> select * from pick_artist( ROW('a','b') );
> on 9.3.
> I don't know what is complaining about in your case.
>
> Luca
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Zhan Li 2013-11-15 14:43:00 How can I call the method in OPTIMIZER_DEBUG?
Previous Message Luca Ferrari 2013-11-14 08:03:43 Re: manipulate and return row inside a function