Re: manipulate and return row inside a function

From: Luca Ferrari <fluca1978(at)infinito(dot)it>
To: Claudio Poli <masterkain(at)gmail(dot)com>
Cc: pgsql novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: manipulate and return row inside a function
Date: 2013-11-14 08:03:43
Message-ID: CAKoxK+7vobCvnkqwkyz7wXZFYO9PiDrbz+TbVVih+H08zSDRkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Claudio Poli 2013-11-14 13:13:15 Re: manipulate and return row inside a function
Previous Message Luca Ferrari 2013-11-14 07:53:36 Re: Datatype of a column