Wednesday, January 12, 2011

Syntax error on line 5475, column 0: Illegal character "\n" (10)

Back in my callow youth, when I learning to program, the bane of my existence was compilers that diagnosed syntax errors thusly:

Yes, parsers always SHOUTED in those days, no lower case on the printers... which wouldn't have helped anyway since keypunches were all upper case as well.

Now, everything's so much better, no more keypunches, and parsers don't shout any more.

But sometimes, the error messages are just as unhelpful:

So what does that mean? Especially when there is no line 5475, the code ends at 5474.

It means you've made a really simple mistake, like a missing quote, and you are being punished by the parser.

Here's one way to find the problem: Open the offending SQL file in dbisql, and run it so you get the same error. Then scroll to the bottom of the file; you will probably see that the syntax coloring is wrong: what should be black and blue is red, and what should be red is black and blue.

Keep scrolling upwards until the coloring is correct again, and at that point you should see where to put the missing quote:
IF @update_diagnostics = '
   THEN ''
   ELSE '\x0d\x0a'

Or where to take out the extra quote.

Or where to fix the
'stupid backquote`
and make it a
'proper quote'.

1 comment:

Anonymous said...

You know, now that we have Deep Blue and genome sequencers and all, you'd think we could do a bit better than this. Not that this is a SA problem in particular, but just sayin'.