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

From Ted Byers
Subject Re: No Return??
Date
Msg-id 912058.2736.qm@web88307.mail.re4.yahoo.com
Whole thread Raw
In response to No Return??  (Bob Pawley <rjpawley@shaw.ca>)
List pgsql-general
--- Bob Pawley <rjpawley@shaw.ca> wrote:

> I'm getting a little frustrated with this problem.
>
> Can anyone tell me what is wrong with the following
> code.
>
> I have tested the portions separately and they all
> work.
>
> When I try it as a whole I get the message "control
> reached end of trigger
> procedure without RETURN."
>
> Any help greatly appreciated.
>
> Bob
>
> Declare
>  pumpnumber integer;
>
>  Begin
>
>  Select count(*) Into pumpnumber From p_id.devices,
> p_id.processes
>  Where device_number = '11'
>  and p_id.devices.fluid_id = p_id.processes.fluid_id
>  and p_id.processes.ip_op_equipment = 'op';
>
>  If pumpnumber = 1 then
>  Update p_id.devices
>  Set number = '#1'
>  From p_id.processes
>  Where p_id.devices.number is null
>  and p_id.devices.device_number = '11'
>  and p_id.devices.fluid_id = p_id.processes.fluid_id
>  and p_id.processes.ip_op_equipment = 'op' ;
>
>  Else If pumpnumber = 2 Then
>  Update p_id.devices
>  Set number = '#2'
>  From p_id.processes
>  Where p_id.devices.number is null
>  and p_id.devices.device_number = '11'
>  and p_id.devices.fluid_id = p_id.processes.fluid_id
>  and p_id.processes.ip_op_equipment = 'op' ;
>
>  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.
>
Look at your flow control!  Your return is within a
conditional block.  If the condition for your first
returns false, flow goes to the very end of the
function and reaches "end" without encountering a
return statement.

Cheers,

Ted

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: VACUUM hanging on PostgreSQL 8.3.1 for larger tables
Next
From: "Paragon"
Date:
Subject: Re: VACUUM hanging on PostgreSQL 8.3.1 for larger tables