Home Contents | # sql:next | Sql | Core4 Lua Commands

## SYNOPSIS

more = query:next()

## DESCRIPTION

After a SELECT statement successfully completes, this function is used to iterate over the result set.

Each time query:next() is called, the next row is retrieved from the database. If no more rows are available, the function returns false.

Once a row is retrieved, it's contents are accessible with the sql:value() function.

## NOTES

After a SELECT statement has successfully executed, the first row of the result set is not yet available. You have to call sql:next() once to access the first result row. This is necessary to be able to distinguish an empty result from an error condition.

## RETURN VALUE

On success, returns true if another row is available and returns false to indicate end of data. On failure, returns nil. In case of an error, the error can be retrieved by calling sql:lastError() on the parent database handle.

## SEE ALSO

sql:bind, sql:prepare, sql:exec, sql:value, sql:reset, sql:finish