Table A.3, “Query Methods” contains the exhaustive list of methods, in alphabetical order. The documentation of each method follows.
Table A.3. Query Methods
Type | Name | Args |
---|---|---|
method |
| 1 |
method |
| 0 |
method |
| 1 |
method |
| 0 |
method |
| 1 |
method |
| 0 |
method |
| 1 |
method |
| 0 |
method |
| 0 |
method |
| 0 |
method |
| 0 |
method |
| 0 |
method |
| 0 |
method |
| 1 |
method |
| 0 |
method |
| 0 |
method |
| 1 |
method |
| 1 |
method |
| 1 |
at()
returns the index of where the cursor
currently is in the result set.
clear()
clears resources related to the query.
isNull?()
Returns true if the query is active and
positioned on a valid record and the field is NULL; otherwise returns
false. Note that for some drivers, isNull()
will not
return accurate information until after an attempt is made to retrieve
data.
def isNull?(index)
index
: the column index.
isValid?()
returns true if the query is currently
positioned on a valid record; otherwise returns false.
exec()
executes SQL. Returns true and sets the query
state to active if the query was successful; otherwise returns false. The query
string must use syntax appropriate for the SQL database being queried (for
example, standard SQL). After the query is executed, the query is positioned on
the first record.
Note that the last error for this query is reset when
exec()
is called.
def exec(sql)
sql
: the SQL to execute.
each()
iterates over the result set, yielding a
record at a time..
[]()
returns the record at the specified index. The
row()
method is an alias for this method.
def [](index)
index
: the index of the record to
returm.
error()
returns a string containing the last error.
moveFirst()
moves the cursor to the first record.
moveLast()
moves the cursor to the last record.
moveNext()
moves the cursor to the next record.
movePrevious()
moves the cursor to the previous record.
rows()
returns the number of rows in the result
set.
rowsAffected()
returns the number of rows affected in a
modifying SQL statement (e.g. UPDATE or DELETE). set.
seek()
moves the cursor to the given index. Returns
true if the seek was positioned on a valid record, false otherwise. If you seek
beyond the end of the set, the cursor will be position will be invalid and
called to row()
will return
nil
.
def seek(index)
index
: the index of the record to
returm.
single()
is like but it returns the first record of
the result set.
def single(sql)
sql
: the SQL to execute.
value()
returns the field value of current record
given by the index.
def value(index)
index
: the column ordinal of the value to return.