GOTO Statement - Oracle to MariaDB Migration

In Oracle, the GOTO statement allows you to unconditionally jump to a specified part of the code.

MariaDB supports the GOTO statement and <<name>> label syntax in the Oracle Compatibility mode.

Oracle:

  -- A sample procedure
  CREATE OR REPLACE PROCEDURE sp1
  AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('A');
 
    GOTO label;
    DBMS_OUTPUT.PUT_LINE('B');
 
    <<label>>
    DBMS_OUTPUT.PUT_LINE('C');
  END;
  /

MariaDB - Oracle Compatibility:

  DROP PROCEDURE IF EXISTS sp1;
 
  DELIMITER //
 
  -- A sample procedure
  CREATE PROCEDURE sp1()
  BEGIN
    SELECT 'A' AS '';
 
    GOTO label;
    SELECT 'B' AS '';
 
    <<label>>
    SELECT 'C' AS '';
  END;
  //
 
  DELIMITER ;

For more information, see Oracle to MariaDB Migration - Oracle Compatibility Mode.