View Ticket
Not logged in
Ticket Hash: 1512de6d8a095a5b59f35d65581d4fcf3cc51f92
Title: Function utility to check if a (possibly text) column is numeric
Status: Closed Type: Feature_Request
Severity: Cosmetic Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2018-07-14 16:54:36
Version Found In:
User Comments:
mj10777 added on 2018-06-24 01:33:40:

Sometimes, in a general purpose, table a field exist to collect data.
In this case 'belongs_to_01' which is defined as text, but I use as a integer.
So the need exists to check if there are any fields, where text has been entered or still contains the default value of '0':

SELECT
 *
FROM gcp_master
WHERE
(
 -- NOT IsNumeric('belongs_to_01') OR
 (belongs_to_01 NOT GLOB '*[0-9]*') OR
 (belongs_to_01 = 0)
)
and then correct any missing entries.
The sqlite3 core function 'typeof' cannot be used for this scenario since the field is defined as text.

Adding [NOT] IsNumeric as a WHERE Sql-Filter in spatialite_gui would also be useful.


sandro added on 2018-07-14 16:54:36:
implemented by commit 34450e315b

please see the new SQL functions IsInteger(), IsDecimalNumber() and IsNumber()