Hi there,
I can't find anywhere a method for changing the delimiter for a query, so that I can manipulate stored routines. For example, trying to execute:
DELIMITER // SELECT NOW()//
with PMA_DBI_query() fails with a syntax error, yet I can change the delimiter in the SQL tab, in the input box below the textarea. But it looks like the queries typed into the SQL tab are executed by import.php.
I've been going crazy all morning trying to find a solution for this. Thanks for any help that you may be able to offer me.
Rouslan
Hi
Dne Wed, 25 May 2011 14:35:44 +0100 Rouslan Placella rouslan@placella.com napsal(a):
I can't find anywhere a method for changing the delimiter for a query, so that I can manipulate stored routines. For example, trying to execute:
DELIMITER // SELECT NOW()//
with PMA_DBI_query() fails with a syntax error, yet I can change the delimiter in the SQL tab, in the input box below the textarea. But it looks like the queries typed into the SQL tab are executed by import.php.
Yes, import.php is responsible for splitting input into multiple queries and they are run separately by PMA_DBI_query. So if you need to split out query, you have to go through import.php.
However if you are generating the query, you should send it part by part using PMA_DBI_query and just set sql_query to show complete query in the user interface.
On Wed, 2011-05-25 at 15:49 +0200, Michal Čihař wrote:
Hi
Dne Wed, 25 May 2011 14:35:44 +0100 Rouslan Placella rouslan@placella.com napsal(a):
I can't find anywhere a method for changing the delimiter for a query, so that I can manipulate stored routines. For example, trying to execute:
DELIMITER // SELECT NOW()//
with PMA_DBI_query() fails with a syntax error, yet I can change the delimiter in the SQL tab, in the input box below the textarea. But it looks like the queries typed into the SQL tab are executed by import.php.
Yes, import.php is responsible for splitting input into multiple queries and they are run separately by PMA_DBI_query. So if you need to split out query, you have to go through import.php.
However if you are generating the query, you should send it part by part using PMA_DBI_query and just set sql_query to show complete query in the user interface.
Yes, I am generating the query on the fly, but I'm not sure how I am supposed to split it. Here's a simple example that I don't know how to handle:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END//
If I first try to execute
DELIMITER //
then PMA_DBI_query straight away returns the following error:
ERROR: Unknown Punctuation String @ 11 STR: // SQL: DELIMITER //
Thanks again for any help with this.
Rouslan
Hi
Dne Wed, 25 May 2011 15:19:52 +0100 Rouslan Placella rouslan@placella.com napsal(a):
Yes, I am generating the query on the fly, but I'm not sure how I am supposed to split it. Here's a simple example that I don't know how to handle:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END//
If I first try to execute
DELIMITER //
then PMA_DBI_query straight away returns the following error:
ERROR: Unknown Punctuation String @ 11 STR: // SQL: DELIMITER //
Thanks again for any help with this.
You don't have to split it at all in this case :-). DELIMITER is not handled by server for single query, so all you have to do is to issue:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END
For displaying purposes, DELIMITER statement might be added, so that user can copy and paste the query.
On Wed, 2011-05-25 at 16:32 +0200, Michal Čihař wrote:
Hi
Dne Wed, 25 May 2011 15:19:52 +0100 Rouslan Placella rouslan@placella.com napsal(a):
Yes, I am generating the query on the fly, but I'm not sure how I am supposed to split it. Here's a simple example that I don't know how to handle:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END//
If I first try to execute
DELIMITER //
then PMA_DBI_query straight away returns the following error:
ERROR: Unknown Punctuation String @ 11 STR: // SQL: DELIMITER //
Thanks again for any help with this.
You don't have to split it at all in this case :-). DELIMITER is not handled by server for single query, so all you have to do is to issue:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END
For displaying purposes, DELIMITER statement might be added, so that user can copy and paste the query.
OMG, you're right, that worked just fine! And I just spend like 3 hours trying to figure out the delimiter business...
Thanks Michal, that was most helpful.
Rouslan
Rouslan Placella a écrit :
On Wed, 2011-05-25 at 16:32 +0200, Michal Čihař wrote:
Hi
Dne Wed, 25 May 2011 15:19:52 +0100 Rouslan Placella rouslan@placella.com napsal(a):
Yes, I am generating the query on the fly, but I'm not sure how I am supposed to split it. Here's a simple example that I don't know how to handle:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END//
If I first try to execute
DELIMITER //
then PMA_DBI_query straight away returns the following error:
ERROR: Unknown Punctuation String @ 11 STR: // SQL: DELIMITER //
Thanks again for any help with this.
You don't have to split it at all in this case :-). DELIMITER is not handled by server for single query, so all you have to do is to issue:
CREATE PROCEDURE `proc`(INOUT p INT(10)) BEGIN SELECT 10 into p; END
For displaying purposes, DELIMITER statement might be added, so that user can copy and paste the query.
OMG, you're right, that worked just fine! And I just spend like 3 hours trying to figure out the delimiter business...
Thanks Michal, that was most helpful.
Rouslan
This whole DELIMITER thing is tricky: it's not part of the SQL syntax (so we cannot send it to server), it's only understood by the mysql client. So we emulated it in the import logic.