Re: PL/PGSQL question

From: Christoph Dalitz <christoph(dot)dalitz(at)hs-niederrhein(dot)de>
To: jc(at)mega-bucks(dot)co(dot)jp
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/PGSQL question
Date: 2003-01-17 08:13:44
Message-ID: 20030117091344.50f698c4.christoph.dalitz@hs-niederrhein.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Date: Fri, 17 Jan 2003 15:09:32 +0900
> From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
>
> I wrote the following plpgsql function. The problem I have is that if no
> rows are found my function returns NULL whereas it should be returning 0.
>
> IF NOT FOUND THEN
> RETURN 0;
> END IF;
> RETURN total_sales;
>
I am not sure how close PL/pgSQL is to the "Persistent Stored Modules" (PSM)
of the SQL3 standard. If it is quite close it has inherited an insane feature
of PSM: "return" does *not* end the function, but only sets the return value.

Check whether the following code works:

IF NOT FOUND THEN
RETURN 0;
ELSE
RETURN total_sales;
END IF;

Christoph Dalitz

Browse pgsql-general by date

  From Date Subject
Next Message kanchana 2003-01-17 10:10:36 Fw: configure error with krb5
Previous Message Patrick Fiche 2003-01-17 08:07:38 Re: PL/PGSQL: another Q