Re: Is there a GoTo ? - Mailing list pgsql-general

From Justin
Subject Re: Is there a GoTo ?
Date
Msg-id CALL-XeP5eQAi_HzH1LNLoWuyxrh_7Ooj6jmNsGF4a8g8upwFQw@mail.gmail.com
Whole thread Raw
In response to Is there a GoTo ?  (İlyas Derse <ilyasderse@gmail.com>)
List pgsql-general
Hi İlyas

As noted by other there is no GOTO

you can move the goto code  into the else statement

or move that code into a new function call and return  that function

or just return null in the else if that is all the it is doing
CREATE OR REPLACE FUNCTION test(i integer) RETURNS integer AS $$
BEGIN
IF i<0 THEN 
RETURN i + 1;
ELSE return second_test( i );
END IF
RETURN null;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION second_test(i integer) RETURNS integer AS $$ BEGIN return abs(i); END; $$ LANGUAGE plpgsql;

 I know TSQL and PL/SQL have this  but look at all the gotchas when constructing code with GOTO's



On Thu, Jan 16, 2020 at 5:53 AM İlyas Derse <ilyasderse@gmail.com> wrote:
In this function I have to GOTO to a label1, but GOTO keyword is not working, can you please help me in getting the way from which I am able to jump from a particular code to label.
 Thanks...

CREATE OR REPLACE FUNCTION test(i integer) RETURNS integer AS $$
BEGIN
IF i<0 THEN 
RETURN i + 1;
ELSE GOTO label1;
END IF
<<label1>>
RETURN null;
END;
$$ LANGUAGE plpgsql;

pgsql-general by date:

Previous
From: Richard van der Hoff
Date:
Subject: Inexplicable duplicate rows with unique constraint
Next
From: Adrian Klaver
Date:
Subject: Re: Inexplicable duplicate rows with unique constraint