Functions

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 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.
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.
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).
void db_CatValArray_sort (dbCatValArray *arr)
 Sort key/value array by key.
int db_CatValArray_sort_by_value (dbCatValArray *arr)
 Sort key/value array by value.
int db_CatValArray_get_value (dbCatValArray *arr, int key, dbCatVal **cv)
 Find value by key.
int db_CatValArray_get_value_int (dbCatValArray *arr, int key, int *val)
 Find value (integer) by key.
int db_CatValArray_get_value_double (dbCatValArray *arr, int key, double *val)
 Find value (double) by key.

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 select.c.


Function Documentation

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

Find value by key.

Parameters:
arr dbCatValArray (key/value array)
key key value
[out] cv dbCatVal structure (key/value) to store within
Returns:
DB_OK on success
DB_FAILED on error

Definition at line 444 of file select.c.

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

Find value (double) by key.

Parameters:
arr dbCatValArray (key/value array)
key key value
[out] val found value (double)
Returns:
DB_OK on success
DB_FAILED on error

Definition at line 496 of file select.c.

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

Find value (integer) by key.

Parameters:
arr dbCatValArray (key/value array)
key key value
[out] val found value (integer)
Returns:
DB_OK on success
DB_FAILED on error

Definition at line 470 of file select.c.

void db_CatValArray_sort ( dbCatValArray *  arr  ) 

Sort key/value array by key.

Parameters:
[in,out] arr dbCatValArray (key/value array)

Definition at line 395 of file select.c.

Referenced by db_select_CatValArray().

int db_CatValArray_sort_by_value ( dbCatValArray *  arr  ) 

Sort key/value array by value.

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

Definition at line 408 of file select.c.

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:
driver DB driver
tab table name
key key column name
col value column name
[out] cvarr dbCatValArray to store within
Returns:
number of selected values
-1 on error

Definition at line 263 of file select.c.

References db_append_string(), db_CatValArray_alloc(), db_CatValArray_sort(), db_close_cursor(), db_fetch(), db_free_string(), db_get_column_sqltype(), db_get_column_value(), db_get_cursor_table(), db_get_num_rows(), db_get_string(), db_get_table_column(), db_get_value_double(), db_get_value_int(), db_get_value_string(), db_init_string(), db_open_select_cursor(), db_set_string(), and db_sqltype_to_Ctype().

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:
driver DB driver
tab table name
col column name
where where statement
[out] pval array of ordered integer values
Returns:
number of selected values
-1 on error

Definition at line 103 of file select.c.

References db_append_string(), db_close_cursor(), db_fetch(), db_free_string(), db_get_column_sqltype(), db_get_column_value(), db_get_cursor_table(), db_get_table_column(), db_get_value_double(), db_get_value_int(), db_get_value_string(), db_init_string(), db_open_select_cursor(), and db_sqltype_to_Ctype().

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:
driver DB driver
tab table name
key key column name
id identifier in key column
col name of column to select the value from
[out] val dbValue to store within
Returns:
number of selected values
-1 on error

Definition at line 200 of file select.c.

References db_append_string(), db_close_cursor(), db_copy_value(), db_fetch(), db_free_string(), db_get_column_value(), db_get_cursor_table(), db_get_table_column(), db_init_string(), and db_open_select_cursor().