The ASIN()
function in SQLite calculates the arc sine (inverse sine) of a given numeric value. The result is the angle in radians whose sine is the specified number.
Category: SQLite
Understanding the ACOS() Function in SQLite
The ACOS()
function in SQLite is used to calculate the arc cosine (inverse cosine) of a given numeric value. The result is the angle in radians whose cosine is the specified number.
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.
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.
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 readingHow to Rename the Columns Returned by the VALUES Statement in SQLite
If you’ve ever used the VALUES
clause as a stand alone statement, you may have noticed that SQLite provides default column names for the results. SQLite conveniently names them column1
, column2
, and so on.
However as convenient as this is, you might want to provide names that are more meaningful.
Fortunately there’s an easy way to do that.
Continue readingFix 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.
Using VALUES instead of SELECT in SQLite
Some database management systems, including SQLite, allow us to use the VALUES
keyword as a stand alone SQL statement. So we can use VALUES
to return a constant table, usually with less code than would be required if we were to use the SELECT
statement.
The following examples demonstrate how.
Continue readingGet 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 readingSQLite CHANGES() Function
The SQLite changes()
function returns the number of database rows that were changed, inserted or deleted by the most recently completed INSERT
, DELETE
, or UPDATE
statement, exclusive of statements in lower-level triggers.
Basically, it allows us to see how many rows are affected when we run any of those statements.
Continue reading