Original Author Paul Laughton, 2011
Page 152
De Re BASIC!
Sql.next <done_lvar>, <cursor_nvar>{, <cv_svars>}
Using the Cursor generated by a previous Query command (Sql.query or Sql.raw_query), step to the
next row of data returned by the Query and retrieve the data.
<done_lvar> is a Boolean variable that signals when the last row of the Query data has been read.
<cursor_nvar> is a numeric variable that holds the Cursor pointer returned by a Query command. You
may have more than one Cursor open at a time.
<cv_svars> is an optional set of column value string variables that return data from the database to your
program. The Cursor carries the values from the table columns listed in the Query. Sql.next retrieves
one row from the Cursor as string values and writes them into the <cv_svars>. If any of your columns are
numeric, you can use the BASIC! VAL(str$) function to convert the strings to numbers.
When this command reads a row of data, it sets the Done flag <done_lvar> to false (0.0). If it finds no
data to read, it changes the Done flag to true (1.0) and resets the cursor variable <cursor_nvar> to zero.
The Cursor can no longer be used for Sql.next operations. The cursor variable may be used with another
Cursor from a different Query.
In its simplest form, <cv_svars> is a comma-separated list of string variable names. Each variable
receives the data of one column. If there are more variables than columns, the excess variables are left
unchanged. If there are more columns than variables, the excess data are discarded.
SQL.NEXT done, cursor, cv1$, cv2$, cv3$
% get data from up to three columns
The last (or only) variable may be a string array name with no index(es):
SQL.NEXT done, cursor, cv$[]
% get data from ALL available columns
The data from any column(s) that are not written to string variables are written into the array. If no
column data are written to the array, the array has one element, an empty string "". If the variable
names an array that already exists, it is overwritten.
If the last (or only) <cv_svars> variable is an array, you may also add (after another comma) a numeric
variable <ncol_nvar>. This variable receives the total number of columns in the cursor. Note that this is
not necessarily the same as the size of the array.
SQL.NEXT done, cursor, cv$[], nCols
% report number of columns available
The full specification for this command, including the optional array and column count, is as follows:
Sql.next <done_lvar>, <cursor_nvar> {, svar}... {, array$[] {, <ncol_nvar>}}
Sql.delete <DB_pointer_nvar>, <table_name_sexp>{,<where_sexp>{,<count_nvar>} }
From the named table of a previously opened database, delete rows selected by the conditions
established by the Where string expression. The Count variable reports the number of rows deleted.