@@ -32,11 +32,7 @@ import ErrorHandling
3232
3333// The generalized result class with variable binding
3434public class SqlResult
35- string v1 = ""
36- string v2 = ""
37- string v3 = ""
38- string v4 = ""
39- // Add up to v30 as needed
35+ string array cols
4036
4137// A full SQL-Select helper
4238public function sqlite_select(int db, string query) returns LinkedList<SqlResult>
@@ -46,15 +42,11 @@ public function sqlite_select(int db, string query) returns LinkedList<SqlResult
4642
4743 while sqlite_step(stmt)
4844 let row = new SqlResult()
49- if cols > 0
50- row.v1 = sqlite_column_string(stmt, 0)
51- if cols > 1
52- row.v2 = sqlite_column_string(stmt, 1)
53- if cols > 2
54- row.v3 = sqlite_column_string(stmt, 2)
55- if cols > 3
56- row.v4 = sqlite_column_string(stmt, 3)
57- // Map more bindings if expanding SqlResult
45+ // SQLite permits up to 2000 columns per result set.
46+ let limit = cols > 2000 ? 2000 : cols
47+ for i = 0 to limit - 1
48+ row.cols[i] = sqlite_column_string(stmt, i)
49+
5850 list.add(row)
5951
6052 sqlite_finalize(stmt)
@@ -85,14 +77,14 @@ function buildAndVerifyDatabase()
8577 if results.size() != 3
8678 error("Expected 3 database entries, found " + results.size().toString())
8779
88- // 5. Verify the highest power is returned first correctly (Arthur is 9000 -> v3 )
80+ // 5. Verify the highest power is returned first correctly (Arthur is 9000 -> cols[2] )
8981 let topHero = results.get(0)
90- if topHero.v1 != "Arthur" or topHero.v3 != "9000"
91- error("Expected Arthur as highest power, but got " + topHero.v1 + " with " + topHero.v3 )
82+ if topHero.cols[0] != "Arthur" or topHero.cols[2] != "9000"
83+ error("Expected Arthur as highest power, but got " + topHero.cols[0] + " with " + topHero.cols[2] )
9284
9385 // 5b. Verify standard fetch
9486 let mageHero = results.get(1)
95- if mageHero.v1 != "Merlin" or mageHero.v2 != "Mage"
87+ if mageHero.cols[0] != "Merlin" or mageHero.cols[1] != "Mage"
9688 error("Validation Failed for Merlin row!")
9789
9890 // 6. Output to the developer console log
0 commit comments