The newer dynamic SQL classes (%SQL.Statement and %StatementResult) perform better than %ResultSet, but I did not adopt them for some time because I had learned how to use %ResultSet. Finally, I made a cheat sheet, which I find useful when writing new code or rewriting old code. I thought other people might find it useful.
First, here is a somewhat more verbose adaptation of my cheat sheet:
1 | %ResultSet::%New() | %SQL.Statement::%New() |
---|---|---|
2 | Call the Prepare() instance method | Call the %Prepare() instance method |
3 | Previous step returns status; check that | Previous step returns status; check that |
4 | Call the Execute() instance method | Call the %Execute() instance method |
5 | Previous step returns status; check that | Previous step returns instance of %SQL.StatementResult; use that in next steps |
6 | Call the Next() instance method (e.g., iteratively, in while loop) | Call the %Next() instance method (e.g., iteratively, in while loop) |
7 | Call the GetData() instance method to get a column by column number | Call the %GetData() instance method to get a column by column number |
Call the Get() or Data() instance method to get a column by column name | Call the %Get() instance method to get a column by column name |
Then here is the terser cheat sheet that I actually use:
1 | %ResultSet::%New() | %SQL.Statement::%New() |
2 | Prepare() | %Prepare() |
3 | Check status | Check status |
4 | Execute() | %Execute() |
5 | Check status | Use value returned by %Execute in next steps |
6 | Next() | %Next() |
7 | GetData() | %GetData() |
Get() or Data() | %Get() |