0

I'm trying to create a script that contains a procedure and then call that procedure. I've done this at work where we use Oracle, but no matter what I try with mariadb, I get an error. So I copied this "simple" proc directly from the MariaDb website, and it ALSO gives the same error:

DELIMITER //

CREATE PROCEDURE simpleproc (OUT param1 INT)
 BEGIN
  SELECT COUNT(*) INTO param1 FROM t;
 END;
//

DELIMITER ;

CALL simpleproc(@a);

Here is the error: Error occurred during SQL script execution

Reason: SQL Error [1064] [42000]: (conn=40) 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 'OUT param1 INT)

Ideas as to how to make this work using dbeaver to connect to mariadb?

Update: I have been able to successfully create a procedure that passes NO parameters (i.e. it just does a select). But if I try to add ANY parameters to the proc, I get the error...

1 Answer 1

0

Inputting your SQL to sqlfiddle.com shows that it can run. The problem seems related to DBeaver rather than MariaDB.

By reading DBeaver issue #24128, I'd say that its "Smart parsing" interfers with your script.
You could look at your Settings -> Editors -> SQL Editor -> SQL Processing or Preferences -> Editors -> SQL Editor -> SQL Processing -> Delimiters to know how it parses script to individual queries; maybe you can set it to a mode so that you don't even have to change DELIMITER.

But if this is a one-shot procedure definition, the simplest way would be to select the procedure definition and "Execute query" instead of "Execute script". Thus you are the parser, instead of DBeaver that gets confused.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! I did trying changing that setting, but it didn't help. I realize this is a really simple proc and I don't "need" a proc for it. I had originally tried my own procedure that was more complex; it passed in several params that it used. But when I couldn't get it to work... I tried something really simple, which still didn't work... I'm sure it must be a config setting somewhere; just not sure where. It works if I don't define any params...
Is it the OUT keyword that baffles DBeaver's parser? What happens when you remove it (apart from the fact that it won't be functional anymore, not returning anything, does it allow you to define it)?
I tried removing the OUT and it still gives an error. I ended up finding a different solution for what I need to by creating a view. Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.