> Hi, My novice question is – I’d like to use EXIT statement to exit a
> block of statements. I copied an example from pg 809 of postgresql 8.4
> documentation but received
>
> Following error. Just want to know correct way to use label. Thanks very
> much.
>
>
>
> ERROR: label does not exist at or near "ablock"
>
> LINE 15: EXIT ablock; -- causes exit from the BEGIN block
>
> ^
>
>
>
> DROP FUNCTION IF EXISTS test_exit();
>
> CREATE OR REPLACE FUNCTION test_exit()
>
> RETURNS void AS
>
> $BODY$
>
>
>
> DECLARE
>
> x integer :=0;
>
> stocks bigint := 100100;
>
>
>
> <<ablock>>
>
> BEGIN
>
> -- some computations
>
> IF stocks > 100000 THEN
>
> EXIT ablock; -- causes exit from the BEGIN
> block
>
> END IF;
>
> -- computations here will be skipped when stocks > 100000
>
>
>
> END;
>
>
>
> $BODY$
>
>
>
> LANGUAGE 'plpgsql' VOLATILE
>
> COST 100;
>
> ALTER FUNCTION test_exit() OWNER TO postgres;
>
>
>
>