From: | Justin <zzzzz(dot)graf(at)gmail(dot)com> |
---|---|
To: | İlyas Derse <ilyasderse(at)gmail(dot)com> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Is there a GoTo ? |
Date: | 2020-01-16 16:55:18 |
Message-ID: | CALL-XeP5eQAi_HzH1LNLoWuyxrh_7Ooj6jmNsGF4a8g8upwFQw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
$$BEGINIF i<0 THEN RETURN i + 1;ELSE
return second_test( i );END IFRETURN 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(at)gmail(dot)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 $$BEGINIF i<0 THEN RETURN i + 1;ELSE
> GOTO label1;END IF<<label1>>RETURN null;END;$$ LANGUAGE plpgsql;
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2020-01-16 17:05:06 | Re: Inexplicable duplicate rows with unique constraint |
Previous Message | Richard van der Hoff | 2020-01-16 16:50:25 | Inexplicable duplicate rows with unique constraint |