class SQLResult

A container for results obtained in an SQLite.exec() call.

Not every SQLite.exec() call will produce results, but any database query (SELECT in particular) will generate an SQLResult object even if the result is empty.

Constructors

new SQLResult();

Constructs a new instance of the SQLResult class

Methods

fieldname

Get the fieldname of a column at a given index

fieldname(index: number): string;
NameTypeDescription
indexnumbercolumn index
Return Valuestringthe name of the column

numfields

Get the number of fields in the dataset returned in the SQLResult object

numfields(): number;
NameTypeDescription
Return Valuenumberthe number of fields

numrecords

Get the number of records were returned in the SQLResult object

numrecords(): number;
NameTypeDescription
Return Valuenumberthe number of records

value

Get the value of a record at a column index and record number

value(index: number, record_no: number): number | string;
NameTypeDescription
indexnumbercolumn index
record_nonumberrecord number
Return Valuenumber | stringthe value of the record

Example

function print_everything(sqlres) {
    var numrecs = sqlres.numrecords()
    var numflds = sqlres.numfields()

    var field_names = new Array()
    for (var i = 0; i < numflds; i++) {
        field_names[i] = sqlres.fieldname(i)
    }

    for (var i = 0; i < numrecs; i++) {
        for (var j = 0; j < numflds; j++) {
            post(
                "Rec: ",
                i,
                " field ",
                field_names[j],
                " value ",
                sqlres.value(j, i),
                "\n"
            )
        }
    }
}