-1

I don't know if it is a simple mistake but couldn't figure out the syntax error in line which contains "NULL;". It says error 1064 on that line. The full message is: ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL;

CREATE  PROCEDURE custom_consumption(IN p_deftype DOUBLE,
                           ...
                           //code part//
                           ...
                           IN p_user DOUBLE,
                           IN p_date DOUBLE,
                           IN p_tid VARCHAR(4000))
  BEGIN
    NULL;
END;


custom_consumption;

This page just shows how to get informed by a visual tool which is How can I fix MySQL error #1064? Thanks for any help. If you see any other mistakes on the code, please inform me.

Mert B.
  • 65
  • 1
  • 1
  • 8
  • 1
    Possible duplicate of [How can I fix MySQL error #1064?](https://stackoverflow.com/questions/23515347/how-can-i-fix-mysql-error-1064) – Panagiotis Kanavos Oct 01 '18 at 12:54
  • Post the *full* message. The error number just says there's a syntax error. The error's text would explain what the error was. Although, `NULL` isn't a statement. – Panagiotis Kanavos Oct 01 '18 at 12:54
  • 1
    what do you think the code is doing? Just writing `NULL` doesn't do anything useful, and anyway it isn't a valid statement by itself. We can tell you to remove it, and that would make that error go away, but it's unclear what you thought you were trying to achieve. Did you mean to _return_ null perhaps? Or _select_ null? – ADyson Oct 01 '18 at 12:56
  • Thanks for the messages. First of all @PanagiotisKanavos it says 'NULL' is not valid at this position, expecting an identifier. And here is the full message: "ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL;" ADyson i actually don't know what is the subject. This is a converted procedure from oracle to mysql. But i guess it is a **return** null – Mert B. Oct 01 '18 at 13:01

1 Answers1

2

Oracle stored procedures allow you to use NULL as a placeholder statement. This allows you to stub your code while still allowing other code within the procedure or package body to compile. MySql does not allow this. If you goal is to stub the code, you need some benign statement.

Sam M
  • 4,136
  • 4
  • 29
  • 42
  • Well, I didn't know that MySql does not allow to use NULL like this. At least that gave me an idea. But also I have a question. What is a "benign" statement? I have already checked some posts about "stubbing the code" but couldn't find anything useful. – Mert B. Oct 01 '18 at 13:53
  • 1
    @MertB. it just means something which is a placeholder - it's valid but does nothing useful. e.g. just `SELECT 1` or something - pointless, but it allows the code to compile and also doesn't do any active damage. – ADyson Oct 01 '18 at 14:29
  • @ADyson 'SELECT' solved the problem. Thanks for the answer. – Mert B. Oct 02 '18 at 08:42