Re: manipulate and return row inside a function - Mailing list pgsql-novice

From Claudio Poli
Subject Re: manipulate and return row inside a function
Date
Msg-id CANp6Qo+XW=9u7LE4aMCT+yhOLyWxBv8ZU0bBg6T2HxPT_T0n2w@mail.gmail.com
Whole thread Raw
In response to Re: manipulate and return row inside a function  (Luca Ferrari <fluca1978@infinito.it>)
List pgsql-novice
I solved it with using COALESCE.

Best,
c.


On Thu, Nov 14, 2013 at 9:03 AM, Luca Ferrari <fluca1978@infinito.it> wrote:
On Thu, Nov 14, 2013 at 8:50 AM, Claudio Poli <masterkain@gmail.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

pgsql-novice by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: manipulate and return row inside a function
Next
From: Zhan Li
Date:
Subject: How can I call the method in OPTIMIZER_DEBUG?