GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bea8435a9e
db/dbmi_client/select.c File Reference

DBMI Library (client) - select records from table. More...

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Include dependency graph for db/dbmi_client/select.c:

Go to the source code of this file.

Functions

int db_select_int (dbDriver *driver, const char *tab, const char *col, const char *where, int **pval)
 Select array of ordered integers from table/column. More...
 
int db_select_value (dbDriver *driver, const char *tab, const char *key, int id, const char *col, dbValue *val)
 Select one (first) value from table/column for key/id. More...
 
int db_select_CatValArray (dbDriver *driver, const char *tab, const char *key, const char *col, const char *where, dbCatValArray *cvarr)
 Select pairs key/value to array, values are sorted by key (must be integer) More...
 
void db_CatValArray_sort (dbCatValArray *arr)
 Sort key/value array by key. More...
 
int db_CatValArray_sort_by_value (dbCatValArray *arr)
 Sort key/value array by value. More...
 
int db_CatValArray_get_value (dbCatValArray *arr, int key, dbCatVal **cv)
 Find value by key. More...
 
int db_CatValArray_get_value_int (dbCatValArray *arr, int key, int *val)
 Find value (integer) by key. More...
 
int db_CatValArray_get_value_double (dbCatValArray *arr, int key, double *val)
 Find value (double) by key. More...
 

Detailed Description

DBMI Library (client) - select records from table.

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Joel Jones (CERL/UIUC), Radim Blazek

Definition in file db/dbmi_client/select.c.

Function Documentation

◆ db_CatValArray_get_value()

int db_CatValArray_get_value ( dbCatValArray arr,
int  key,
dbCatVal **  cv 
)

Find value by key.

Parameters
arrdbCatValArray (key/value array)
keykey value
[out]cvdbCatVal structure (key/value) to store within
Returns
DB_OK on success
DB_FAILED on error

Definition at line 465 of file db/dbmi_client/select.c.

◆ db_CatValArray_get_value_double()

int db_CatValArray_get_value_double ( dbCatValArray arr,
int  key,
double *  val 
)

Find value (double) by key.

Parameters
arrdbCatValArray (key/value array)
keykey value
[out]valfound value (double)
Returns
DB_OK on success
DB_FAILED on error

Definition at line 515 of file db/dbmi_client/select.c.

◆ db_CatValArray_get_value_int()

int db_CatValArray_get_value_int ( dbCatValArray arr,
int  key,
int *  val 
)

Find value (integer) by key.

Parameters
arrdbCatValArray (key/value array)
keykey value
[out]valfound value (integer)
Returns
DB_OK on success
DB_FAILED on error

Definition at line 490 of file db/dbmi_client/select.c.

◆ db_CatValArray_sort()

void db_CatValArray_sort ( dbCatValArray arr)

Sort key/value array by key.

Parameters
[in,out]arrdbCatValArray (key/value array)

Definition at line 417 of file db/dbmi_client/select.c.

References dbCatValArray::n_values, and dbCatValArray::value.

◆ db_CatValArray_sort_by_value()

int db_CatValArray_sort_by_value ( dbCatValArray arr)

Sort key/value array by value.

Parameters
[in,out]arrdbCatValArray (key/value array)
Returns
DB_OK on success
DB_FAILED on error

Definition at line 430 of file db/dbmi_client/select.c.

References dbCatValArray::ctype, DB_C_TYPE_INT, dbCatValArray::n_values, and dbCatValArray::value.

◆ db_select_CatValArray()

int db_select_CatValArray ( dbDriver driver,
const char *  tab,
const char *  key,
const char *  col,
const char *  where,
dbCatValArray cvarr 
)

Select pairs key/value to array, values are sorted by key (must be integer)

Parameters
driverDB driver
tabtable name
keykey column name
colvalue column name
[out]cvarrdbCatValArray to store within
Returns
number of selected values
-1 on error

Definition at line 269 of file db/dbmi_client/select.c.

◆ db_select_int()

int db_select_int ( dbDriver driver,
const char *  tab,
const char *  col,
const char *  where,
int **  pval 
)

Select array of ordered integers from table/column.

Parameters
driverDB driver
tabtable name
colcolumn name
wherewhere statement
[out]pvalarray of ordered integer values
Returns
number of selected values
-1 on error

Definition at line 103 of file db/dbmi_client/select.c.

Referenced by Vect_cats_set_constraint().

◆ db_select_value()

int db_select_value ( dbDriver driver,
const char *  tab,
const char *  key,
int  id,
const char *  col,
dbValue val 
)

Select one (first) value from table/column for key/id.

Parameters
driverDB driver
tabtable name
keykey column name
ididentifier in key column
colname of column to select the value from
[out]valdbValue to store within
Returns
number of selected values
-1 on error

Definition at line 204 of file db/dbmi_client/select.c.