SQLResultSetRead[rs]
shifts the current position and then reads a row from a result set.
SQLResultSetRead[rs,num]
reads num rows from a result set.
Details and Options
Examples
Basic Examples
Options
"GetAsStrings"
Applications
See Also
Tech Notes
Related Guides
DatabaseLink`
DatabaseLink`
SQLResultSetRead
SQLResultSetRead[rs]
shifts the current position and then reads a row from a result set.
SQLResultSetRead[rs,num]
reads num rows from a result set.
Details and Options
- To use SQLResultSetRead, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- The following option can be given:
-
"GetAsStrings" False return the results as strings
Examples
open all close allBasic Examples (1)
Needs["DatabaseLink`"]If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the DatabaseLink`DatabaseExamples` package, as described in Using the Example Databases.
conn = OpenSQLConnection["publisher"];rs = SQLResultSetOpen[SQLSelect[conn, "roysched"]];SQLResultSetRead[rs]Read the second and third rows:
SQLResultSetRead[rs, 2]SQLResultSetGoto[rs, Infinity];SQLResultSetRead[rs, -4]SQLResultSetClose[rs]CloseSQLConnection[conn];Options (1)
"GetAsStrings" (1)
Needs["DatabaseLink`"]conn = OpenSQLConnection["publisher"];rs = SQLResultSetOpen[SQLSelect[conn, "roysched"]];SQLResultSetRead[rs, "GetAsStrings" -> True]//InputFormSQLResultSetClose[rs]CloseSQLConnection[conn];Applications (1)
Needs["DatabaseLink`"]Process each row individually, and get the sum:
conn = OpenSQLConnection["publisher"];rs = SQLResultSetOpen[SQLSelect[conn, "roysched", "royalty"]];res = 0;While[ListQ[data = SQLResultSetRead[rs]], res += data[[1]]];
resSQLResultSetClose[rs]CloseSQLConnection[conn];