Home  Contents

sql:value

Sql Core4 Lua Commands

SYNOPSIS

value = query:value(columnindex[, type])

DESCRIPTION

This function is used to retrieve the values returned by a SELECT statement. It can only return data if a SELECT statement has executed successfully and sql:next() has indicated that data is available.

The parameter columnindex indicates the column number within the result set, starting at 1. For example, if a SELECT statement looked like SELECT Name, Address, City FROM …, then column number 1 indicates the Name column, number 2 indicates the Address and number 3 indicates the City column.

Normally the data type of the return value is as it was found inside the database. Optionally the data can be coerced to a specific type. Pass one of the following strings as type: "integer", "text" or "blob".

RETURN VALUE

Returns the value requested. If there is no value available or the value is NULL, returns nil. There is no further error reporting.

SEE ALSO