mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-21 11:13:54 +03:00
Added IFNULL and NVL functions. (CVS 401)
FossilOrigin-Name: c6a85c8ee3d653a294bcc033ac6cab2b6de06f96
This commit is contained in:
16
src/func.c
16
src/func.c
@@ -16,7 +16,7 @@
|
||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: func.c,v 1.6 2002/02/28 00:41:10 drh Exp $
|
||||
** $Id: func.c,v 1.7 2002/02/28 00:46:26 drh Exp $
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
@@ -165,6 +165,18 @@ static void lowerFunc(sqlite_func *context, int argc, const char **argv){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the IFNULL() and NVL() functions. (both do the
|
||||
** same thing. They return their first argument if it is not NULL or
|
||||
** their second argument if the first is NULL.
|
||||
*/
|
||||
static void ifnullFunc(sqlite_func *context, int argc, const char **argv){
|
||||
const char *z;
|
||||
assert( argc==2 );
|
||||
z = argv[0] ? argv[0] : argv[1];
|
||||
sqlite_set_result_string(context, z, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
** An instance of the following structure holds the context of a
|
||||
** sum() or avg() aggregate computation.
|
||||
@@ -350,6 +362,8 @@ void sqliteRegisterBuildinFunctions(sqlite *db){
|
||||
{ "round", 2, roundFunc },
|
||||
{ "upper", 1, upperFunc },
|
||||
{ "lower", 1, lowerFunc },
|
||||
{ "ifnull", 2, ifnullFunc },
|
||||
{ "nvl", 2, ifnullFunc },
|
||||
};
|
||||
static struct {
|
||||
char *zName;
|
||||
|
Reference in New Issue
Block a user