Re: Is there a GoTo ?

Поиск
Список
Период
Сортировка
От Justin
Тема Re: Is there a GoTo ?
Дата
Msg-id CALL-XeP5eQAi_HzH1LNLoWuyxrh_7Ooj6jmNsGF4a8g8upwFQw@mail.gmail.com
обсуждение исходный текст
Ответ на Is there a GoTo ?  (İlyas Derse <ilyasderse@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Richard van der Hoff
Дата:
Сообщение: Inexplicable duplicate rows with unique constraint
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Inexplicable duplicate rows with unique constraint