Re: PL/PGSQL question - Mailing list pgsql-general

From Christoph Dalitz
Subject Re: PL/PGSQL question
Date
Msg-id 20030117091344.50f698c4.christoph.dalitz@hs-niederrhein.de
Whole thread Raw
In response to PL/PGSQL question  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
> Date: Fri, 17 Jan 2003 15:09:32 +0900
> From: Jean-Christian Imbeault <jc@mega-bucks.co.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

pgsql-general by date:

Previous
From: "Stefan Scherf"
Date:
Subject: temporary tables on hd or in memory?
Next
From: "kanchana"
Date:
Subject: Fw: configure error with krb5