Tag Archives: sql

Error messages

My course load is the same as it usually is every spring:

  • Intermediate programming (CSCI 13)
  • Discrete structures for CS (CSCI 26)
  • System programming in C (CSCI 46)
  • Introduction to SQL (CSCI 52)

In my students I see the usual patterns emerging: some students pay zero attention to compiler error messages. They do notice the existence of the message, but don’t actually read it. Rather, they just go back to the source code and stare at it, trying to figure out where the error could be. If I happen to be looking over their shoulders when the message pops up, I read it to them, point out the line number, and then show how the message correlates to their code. But, alas, for some students it doesn’t appear to sink in.

This phenomenon only happens with the traditional programming languages: Java, C, and the like. It does not happen in my SQL class. There, the students without fail diligently read the error message and make corrections to their code.

Why is this?

It’s the interactive nature of the SQL user interface. Type in a query, press Enter, and the computer compiles and executes it right on the spot. If there is an error, the message appears right below the input and, often, there is an arrow pointing at the exact character where the compiler noticed the error.

db=> select name, balance from account were balance < 200;
ERROR:  syntax error at or near "balance"
LINE 1: select name, balance from account were balance < 200;
                                               ^

See the arrow pointing at “balance?”

Contrast this with a traditional compiler, whose error messages appear detached from the actual source code, and frequently in abundance. It’s not only overwhelming to the beginning student, it’s very difficult to connect the error message with the location in the code.

IDEs and text editors could certainly help out. How about graphical “speech balloons” pointing at the troublesome code?

Advertisements