The value class represents a single value of any type.
API Reference Overview
void duckdb_destroy_value(duckdb_value *value); duckdb_value duckdb_create_varchar(const char *text); duckdb_value duckdb_create_varchar_length(const char *text, idx_t length); duckdb_value duckdb_create_int64(int64_t val); duckdb_value duckdb_create_struct_value(duckdb_logical_type type, duckdb_value *values); duckdb_value duckdb_create_list_value(duckdb_logical_type type, duckdb_value *values, idx_t value_count); duckdb_value duckdb_create_array_value(duckdb_logical_type type, duckdb_value *values, idx_t value_count); char *duckdb_get_varchar(duckdb_value value); int64_t duckdb_get_int64(duckdb_value value); duckdb_destroy_value
Destroys the value and de-allocates all memory allocated for that type.
Syntax
void duckdb_destroy_value( duckdb_value *value ); Parameters
value
The value to destroy.
duckdb_create_varchar
Creates a value from a null-terminated string
Syntax
duckdb_value duckdb_create_varchar( const char *text ); Parameters
value
The null-terminated string
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_create_varchar_length
Creates a value from a string
Syntax
duckdb_value duckdb_create_varchar_length( const char *text, idx_t length ); Parameters
value
The text
length
The length of the text
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_create_int64
Creates a value from an int64
Syntax
duckdb_value duckdb_create_int64( int64_t val ); Parameters
value
The bigint value
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_create_struct_value
Creates a struct value from a type and an array of values
Syntax
duckdb_value duckdb_create_struct_value( duckdb_logical_type type, duckdb_value *values ); Parameters
type
The type of the struct
values
The values for the struct fields
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_create_list_value
Creates a list value from a type and an array of values of length value_count
Syntax
duckdb_value duckdb_create_list_value( duckdb_logical_type type, duckdb_value *values, idx_t value_count ); Parameters
type
The type of the list
values
The values for the list
value_count
The number of values in the list
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_create_array_value
Creates a array value from a type and an array of values of length value_count
Syntax
duckdb_value duckdb_create_array_value( duckdb_logical_type type, duckdb_value *values, idx_t value_count ); Parameters
type
The type of the array
values
The values for the array
value_count
The number of values in the array
returns
The value. This must be destroyed with duckdb_destroy_value.
duckdb_get_varchar
Obtains a string representation of the given value. The result must be destroyed with duckdb_free.
Syntax
char *duckdb_get_varchar( duckdb_value value ); Parameters
value
The value
returns
The string value. This must be destroyed with duckdb_free.
duckdb_get_int64
Obtains an int64 of the given value.
Syntax
int64_t duckdb_get_int64( duckdb_value value ); Parameters
value
The value
returns
The int64 value, or 0 if no conversion is possible