Re: pgplsql - Oracle nvl

From: darren(at)crystalballinc(dot)com
To: Christian Traber <christian(at)traber-net(dot)de>
Cc: Csaba Nagy <nagy(at)ecircle-ag(dot)com>, Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: pgplsql - Oracle nvl
Date: 2003-08-28 02:54:16
Message-ID: Pine.LNX.4.44.0308272252260.23566-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you want to keep the same functions just do as follows

CREATE OR REPLACE FUNCTION nvl(TEXT,TEXT) RETURNS TEXT AS '
BEGIN
RETURN COALESCE($1,$2);
END;' LANGUAGE 'plpgsql';

You will have to do this for all supported data types unless you want to
put in a third parameter that would be the cast type

HTH

Darren

On Wed, 27 Aug 2003, Christian Traber wrote:

> I know this functions, but I do not want to change the statements in my
> old application.
> So I want to make the functions with the Oracle names for compatibility.
>
> Best regards,
> Christian
>
> Csaba Nagy wrote:
>
> >You don't need to build any function for this, you have them ready:
> >http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=functions-conditional.html#AEN9753
> >http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=functions-conditional.html#AEN9698
> >
> >Cheers,
> >Csaba.
> >
> >On Wed, 2003-08-27 at 09:58, Christian Traber wrote:
> >
> >
> >>Hi,
> >>
> >>I'll try to switch from Oracle to postgres for some small applications.
> >>Is it possible to build functions like Oracle's nvl or decode with pgplsql?
> >>How can I make a function like nvl that works for every datatype?
> >>
> >>Best regards,
> >>Christian
> >>
> >>
> >>
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 6: Have you searched our list archives?
> >>
> >> http://archives.postgresql.org
> >>
> >>
> >
> >
> >
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

--
Darren Ferguson

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-08-28 02:58:09 Re: SQL Command - To List Tables ?
Previous Message Tom Lane 2003-08-28 02:46:47 Re: plpgsql FOUND Variable