counter customizable free hit

Thursday, March 16, 2006

Do you really want to comment out that code?

Yet again I have been on the MySQL forums and yet again it's given me something to write about. The question was pretty standard simply asking how you comment out code or add comments to MySQL stored routines. However the wording of the question got me thinking. In the past when I have been writing complex stored procedures in Oracle it can be difficult to see where an error is coming from, not necessarily which line is raising the error but which section of code cause the problem. One of the methods I have used in the past is to use the /* */ multi line comment syntax to exclude blocks of code on mass to rule them out quickly, this has proved a good way to narrow down where the root of an error comes from.

But as you may know MySQL simply removes any comments from the code if it's entered via the command line, it makes no distinction between comments you are adding and code which has been commented out. This isn't a problem when you write procedures in script files and upload them but if you use the command line directly (either typing them in or copy and paste) it means the commented code will be lost forever.

Yet another example of why you don't want to write stored procedures directly into the command line.


Post a Comment

<< Home