Search Postgresql Archives

Re: Is there a GoTo ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux