Re: No Return?? - Mailing list pgsql-general

From Sam Mason
Subject Re: No Return??
Date
Msg-id 20080413202612.GG6870@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to No Return??  (Bob Pawley <rjpawley@shaw.ca>)
List pgsql-general
On Sun, Apr 13, 2008 at 01:07:26PM -0700, Bob Pawley wrote:
> When I try it as a whole I get the message "control reached end of trigger
> procedure without RETURN."

I've re-indented the code to make it a bit more obvious what's going on
in your old version:

> DECLARE
>   pumpnumber integer;
> BEGIN
>   SELECT count(*) INTO pumpnumber [...]
>   IF pumpnumber = 1 THEN
>     UPDATE p_id.devices [...]
>   ELSE
>     IF pumpnumber = 2 THEN
>       UPDATE p_id.devices [...]
>     END IF;
>     RETURN NULL;
>   END IF;
> END;
>
> I have tried 'Return New' and 'Return Result' without luck, and if I leave
> off either of the two 'End If ' statements the procedure returns an error.

I think you're looking for either "ELSIF" or "ELSEIF", you've got
white space between the ELSE and the IF which is introducing a new
sub-expression.  Either that, or move the RETURN after the final END IF.


  Sam

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: No Return??
Next
From: "Paragon"
Date:
Subject: Re: VACUUM hanging on PostgreSQL 8.3.1 for larger tables