SQLite’s json_valid() Now Accepts an Argument that Defines What “Valid” Means

SQLite’s json_valid() function allows us to check whether a JSON string is well formed or not.

Prior to SQLite 3.45.0 the json_valid() function only accepts one argument – the value to check. However, from SQLite 3.45.0 (released on 15 January 2024), we can now provide an optional second argument to define what valid – or “well formed” – means.

Continue reading

Fix ‘Parse error: near “LIMIT”‘ in SQLite When Using the VALUES Statement

If you’re getting a SQLite error that reads ‘Parse error: near “LIMIT”‘, it could be that you’re trying to use the LIMIT clause when using the VALUES clause as a stand alone statement.

SQLite doesn’t allow us to apply the LIMIT clause against the VALUES statement.

However, there is a work around. Below is an example of how we can apply the LIMIT clause against the VALUES statement.

Continue reading

Fix “Parse error: all VALUES must have the same number of terms” in SQLite when using the VALUES Stand Alone Statement

If you’re getting an error that reads “Parse error: all VALUES must have the same number of terms” in SQLite when using the VALUES clause as a stand alone statement, it’s probably because you’re not providing the same number of columns in all rows.

When we use VALUES to create a constant table, we must provide the same number of columns in each row.

To fix this issue, be sure to provide the same number of columns across all rows.

Continue reading

Fix SQLite ‘Parse error: near “ORDER”‘ When Using VALUES as a Stand Alone Statement

If you’re getting an error that reads ‘Parse error: near “ORDER”‘ in SQLite, it could be that you’re trying to use the ORDER BY clause when using the VALUES clause as a stand alone statement.

Although we can certainly use the VALUES clause as a stand alone SQL statement, we can’t apply the ORDER BY clause against it.

However all is not lost. Below is an example of how we can sort the results of the VALUES statement.

Continue reading

Get the Number of Rows Affected by Previous SQL Statement

Some RDBMSs provide an easy way for us to find out how many rows were affected by the last SQL statement. This can be handy when running INSERT, UPDATE, or DELETE statements.

The method used depends on the DBMS we’re using. Below, I look at how some of the major DBMSs implement this functionality.

Continue reading