Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-19150

sql_mode="oracle" errors on create procedure AS

Details

    Description

      proc

      CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER;
         BEGIN
            DELETE FROM employees
            WHERE employees.employee_id = remove_emp.employee_id;
         tot_emps := tot_emps - 1;
         END;
      /
      

      error:

      MariaDB [test]> CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
      

      Attachments

        Activity

          By the way, there should not be a semicolon after NUMBER. It should be followed by BEGIN immediately.

          manjot, can you clarify please, what is the problem?
          Does it work for you if you remove the redundant semicolon and add DELIMITER commands?

          bar Alexander Barkov added a comment - By the way, there should not be a semicolon after NUMBER. It should be followed by BEGIN immediately. manjot , can you clarify please, what is the problem? Does it work for you if you remove the redundant semicolon and add DELIMITER commands?
          manjot Manjot Singh (Inactive) added a comment - - edited

          This example with semi colon works in pl/sql. I believe this is from one of
          oracle's tutorials.

          Thanks,
          Manjot Singh

          On Mon, Sep 9, 2019, 7:47 PM Alexander Barkov (Jira) <jira@mariadb.org>

          manjot Manjot Singh (Inactive) added a comment - - edited This example with semi colon works in pl/sql. I believe this is from one of oracle's tutorials. Thanks, Manjot Singh On Mon, Sep 9, 2019, 7:47 PM Alexander Barkov (Jira) <jira@mariadb.org>

          manjot Sorry, the semicolon is OK.

          So this script works without problems in MariaDB:

          SET sql_mode=ORACLE;
          DELIMITER /
          CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER;
             BEGIN
                DELETE FROM employees
                WHERE employees.employee_id = remove_emp.employee_id;
             tot_emps := tot_emps - 1;
             END;
          /
          DELIMITER ;
          

          Should we close the issue?

          bar Alexander Barkov added a comment - manjot Sorry, the semicolon is OK. So this script works without problems in MariaDB: SET sql_mode=ORACLE; DELIMITER / CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER; BEGIN DELETE FROM employees WHERE employees.employee_id = remove_emp.employee_id; tot_emps := tot_emps - 1; END ; / DELIMITER ; Should we close the issue?
          bar Alexander Barkov added a comment - - edited

          I just tested with 10.3.14, this script works without problems:

          SET sql_mode=ORACLE;
          DELIMITER /
          CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER;
             BEGIN
                DELETE FROM employees
                WHERE employees.employee_id = remove_emp.employee_id;
             tot_emps := tot_emps - 1;
             END;
          /
          DELIMITER ;
          

          You got a syntax error because you forgot the DELIMITER command before CREATE PROCEDURE.

          So this query fragment:

          CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER;
          

          is interpreted by the "mysql" command line client as a separate statement.
          The server returns a syntax error because on unexpected end-of-query.

          bar Alexander Barkov added a comment - - edited I just tested with 10.3.14, this script works without problems: SET sql_mode=ORACLE; DELIMITER / CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER; BEGIN DELETE FROM employees WHERE employees.employee_id = remove_emp.employee_id; tot_emps := tot_emps - 1; END ; / DELIMITER ; You got a syntax error because you forgot the DELIMITER command before CREATE PROCEDURE. So this query fragment: CREATE PROCEDURE remove_emp (employee_id NUMBER) AS tot_emps NUMBER; is interpreted by the "mysql" command line client as a separate statement. The server returns a syntax error because on unexpected end-of-query.

          People

            Unassigned Unassigned
            manjot Manjot Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.