Bug #19150 batch statements
Submitted: 17 Apr 2006 20:59 Modified: 25 Apr 2006 20:49
Reporter: cristian vanti Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version:5.1 OS:Any (all)
Assigned to: CPU Architecture:Any

[17 Apr 2006 20:59] cristian vanti
Description:
I've just found that I can't use IF, DECLARE, BEGIN..END, ... outside stored procedure. I used Oracle and Sybase/Microsoft for years and I consider these features basic. I can't imagine how to write upgrade script without them. I tried to write dummy sp but I can't use sp manipulation commands inside it. Oracle wasn't built in one day, but ...

How to repeat:
write BEGIN END; and execute it
[24 Apr 2006 9:07] Valeriy Kravchuk
Thank you for a reasonable feature request (to implement something similar to Oracle PL/SQL's anonymous blocks). I am not sure it will be implemented in the foreseeable future, though, because it is not included in SQL 2003 Standard.
[25 Apr 2006 20:49] cristian vanti
SQL 2003 can be a priority for you but MySQL lacks of batch processing capabilities. I'm thinking about SQL*Plus scripting. But not only.
At now I'm involved in a MS SqlServer to MySql migration project and I've a lot of schema manipulation scripts with this kind of statements:
IF NOT EXISTS (select 1 from sysobject where name = 'objname')
BEGIN
...
END
ELSE
BEGIN

...
END

I resolved instructing my translator to build a dummy stored procedures and calling them.  But it isn't very comfortable. Also because I can't create/drop procedure inside another one.

bye
cristian