SQLITE_RANGE: column index out of range
A parameter number passed to an sqlite3_bind function, or a column number passed to an sqlite3_column function, is outside the valid range.
- Result code
SQLITE_RANGE- Name
25- Category
- Primary result codes
What it means
SQLITE_RANGE (25) means a bind or column index doesn't exist in the statement. Parameter numbers start at 1, and the highest is the number of ? placeholders (or the largest ?NNN). Language bindings report the same mistake when you pass more values than the statement has placeholders, for example Python's Incorrect number of bindings supplied.
Common causes
- Binding parameter 0, or one more parameter than the statement has.
- Passing a list of values that doesn't match the number of
?placeholders. - Reading a column index beyond the number of result columns.
- Putting
?inside quotes, where it is a literal question mark, not a placeholder.
How to fix it
-
Count the placeholders and pass exactly that many values. Bind indexes start at 1.
-
Use named parameters to avoid counting mistakes.
SELECT * FROM users WHERE email = :email AND status = :status;
-
Never quote a placeholder: write
WHERE name = ?, notWHERE name = '?'.
Related errors
SQLITE_MISUSEbad parameter or other API misuseSQLITE_ERRORSQL logic errorORA-01008Oracle: not all variables bound
More primary result codes errors
SQLITE_PERMaccess permission deniedSQLITE_ABORTquery abortedSQLITE_BUSYdatabase is lockedSQLITE_LOCKEDdatabase table is lockedSQLITE_NOMEMout of memorySQLITE_READONLYattempt to write a readonly databaseSQLITE_INTERRUPTinterruptedSQLITE_IOERRdisk I/O error
The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.
Work on SQLite in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.