Re: No Return??

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: No Return??
Date: 2008-04-13 20:26:12
Message-ID: 20080413202612.GG6870@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paragon 2008-04-13 22:02:12 Re: VACUUM hanging on PostgreSQL 8.3.1 for larger tables
Previous Message Adrian Klaver 2008-04-13 20:20:50 Re: No Return??