A few lessons learned today from working with MySQL variables,
WHILE loops, and prepared statements:
- In a continuation statement for the
WHILEloop, make sure to use user-defined variables (i.e.
DECLARE foo INT DEFAULT 10as opposed to
SET @foo = 10, which defines a session variable called
@footo be 10)
- When using these user-defined variables, be sure to
DECLAREthem before any other code gets executed. I’m embarrassed to say that this is one of the things that confounded me the most, despite having written more lines in C than in probably any other language.
More to come as this project continues!