PrevUpHomeNext

Function Calls

Pre-wrapped functions
Scalar and Aggregate Functions
Writing Your Own Function Wrappers

Quince defines C++ functions that wrap certain SQL functions; i.e. they build and return exprn_mappers that represent SQL function calls.

E.g., if str is some abstract_mapper<std::string>, then length(str) builds an exprn_mapper<int32_t> which, when executed, evaluates the SQL subexpression represented by str, and passes the result to the SQL length function.

Here is a list of all the quince functions that wrap SQL functions in this way:

Quince function name

Argument is abstract_mapper<...>

Returns exprn_mapper<...>

SQL function name

abs

int16_t

int16_t

abs

abs

int32_t

int32_t

abs

abs

int64_t

int64_t

abs

abs

float

float

abs

abs

double

double

abs

lower

std::string

std::string

lower

upper

std::string

std::string

upper

length

std::string

int32_t

length

avg

int16_t

boost::optional<double>

avg

avg

int32_t

boost::optional<double>

avg

avg

int64_t

boost::optional<double>

avg

avg

float

boost::optional<double>

avg

avg

double

boost::optional<double>

avg

count

any type

int64_t

count

sum

int16_t

int64_t

sum

sum

int32_t

int64_t

sum

sum

int64_t

int64_t

sum

sum

float

double

sum

sum

double

double

sum

max

any single-column type T

boost::optional<T>

max

min

any single-column type T

boost::optional<T>

min

Function constants

Quince defines two function constants:

  • count_all is an exprn_mapper<int64_t> that wraps SQL's COUNT(*)
  • empty is a predicate (i.e. an exprn_mapper<bool>). It is defined as count_all==int64_t(0).

E.g.:

const query<int64_t> n_points = points.select(count_all);
const query<bool> no_points = points.select(empty);

As we shall see, quince provides special means of creating and executing queries that end in .select(count_all) or .select(empty).


PrevUpHomeNext