delimiter support?

[expired user #1784]'s profile image [expired user #1784] posted 17 years ago in General Permalink
hi,

first of all, great improvements in RC4 :D

my problem: i want to create a stored procedure like in:

-----------------------------------------------

USE ...;

DROP TABLE IF EXISTS foo;
CREATE TEMPORARY TABLE IF NOT EXISTS foo (...);

DROP PROCEDURE IF EXISTS bar;
DELIMITER '/';
CREATE PROCEDURE bar (...)
BEGIN
...
END/
DELIMITER ';'/

CALL bar(...);

SELECT * FROM foo;

-----------------------------------------------

but when executed then an error message concerning the syntax of "delimiter" pops up. is there a chance that delimiter will be supported? i know that someone asked about this in january 2007, but there was no answer to his or her post ...
ansgar's profile image ansgar posted 17 years ago Permalink
I didn't know this command DELIMITER yet. What's the goal of its use? I assume the semicolon is always good isn't it?
[expired user #1784]'s profile image [expired user #1784] posted 17 years ago Permalink
it's needed to define stored procedures:

DELIMITER '/';
CREATE PROCEDURE bar (...)
BEGIN
DO CLEVER STUFF;
DO MORE CLEVER STUFF
DO EVEN MORE CLEVER STUFF;
END/
DELIMITER ';'/

if there was no way to change the delimiter then the CREATE PROCEDURE command would be ended after the first ';' (and the execution would break with syntax error).

by changing the delimiter one is able to use the ';' as delimiter inside the procedure definition and at the same time end the CREATE PROCEDURE command with the previously set delimiter '/' (END/). after the procedure definition the delimiter is changed back to ';' so the stored procedure can be executed.

sadly there is no way to 'box' the BEGIN ... END block (like for example with '[]', '""' or '{}').
[expired user #1537]'s profile image [expired user #1537] posted 17 years ago Permalink
Strangely, I was just coming on today to post a request for this functionality. It would definitely be better then switching to command line (or another client) when I need this.
ansgar's profile image ansgar posted 17 years ago Permalink
ah: Revision 674 has a button which switches the default delimiter to // instead of ; so you can use that whithin these statements.

http://svn.sourceforge.net/heidisql/?rev=674&view=rev
[expired user #2778]'s profile image [expired user #2778] posted 17 years ago Permalink
Will the installer be updated any time soon to incorporate this?

Also, why not make it so that the "delimiter" command was just supported?

Please login to leave a reply, or register at first.