Here is the isnumeric function. Don't forget to add the line to the
sqlite3RegisterBuiltinFunctions function.
{ "isnumeric", 1, 0, SQLITE_UTF8, 0, isnumericFunc},
I put it right after the abs function declartation
/*
----------------------------------------------------------------------------
----------*/
/*
** Implementation of the isnumeric() function
*/
static void isnumericFunc(sqlite3_context *context, int argc, sqlite3_value
**argv)
{
int i;
int nResult = 1;
assert( argc==1 );
switch( sqlite3_value_type(argv[0]) ){
case SQLITE_INTEGER: {
sqlite3_result_int(context, 1);
break;
}
case SQLITE_NULL: {
sqlite3_result_int(context, 0);
break;
}
case SQLITE_TEXT: {
const char *z = sqlite3_value_text(argv[0]);
for (i = 0; i < strlen (z); i++) {
if (!isdigit (z[i])) {
nResult = 0;
break;
}
}
sqlite3_result_int(context, nResult);
break;
}
default: {
sqlite3_result_int(context, 0);
break;
}
}
}
/*
----------------------------------------------------------------------------
----------*/
Michael Evenson
P.s.
It sure would be nice to have this in the next release