grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

copy_tab.c File Reference

DBMI Library (client) - copy table. More...

#include <stdlib.h>
#include <string.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
#include "macros.h"
Include dependency graph for copy_tab.c:

Go to the source code of this file.

Functions

static int cmp (const void *pa, const void *pb)
 
static int copy_table (const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname, const char *where, const char *select, const char *selcol, int *ivals, int nvals)
 Copy table, used by various db_copy_table* (internal use only) More...
 
int db_copy_table (const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname)
 Copy a table. More...
 
int db_copy_table_where (const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname, const char *where)
 Copy a table (by where statement) More...
 
int db_copy_table_select (const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname, const char *select)
 Copy a table (by select statement) More...
 
int db_copy_table_by_ints (const char *from_drvname, const char *from_dbname, const char *from_tblname, const char *to_drvname, const char *to_dbname, const char *to_tblname, const char *selcol, int *ivals, int nvals)
 Copy a table (by keys) More...
 

Detailed Description

DBMI Library (client) - copy 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 copy_tab.c.

Function Documentation

◆ cmp()

static int cmp ( const void *  pa,
const void *  pb 
)
static

Definition at line 21 of file copy_tab.c.

Referenced by copy_table().

◆ copy_table()

static int copy_table ( const char *  from_drvname,
const char *  from_dbname,
const char *  from_tblname,
const char *  to_drvname,
const char *  to_dbname,
const char *  to_tblname,
const char *  where,
const char *  select,
const char *  selcol,
int *  ivals,
int  nvals 
)
static

Copy table, used by various db_copy_table* (internal use only)

Use either 'where' or 'select' or 'selcol'+'ivals'+'nvals' but never more than one.

Warning: driver opened as second must be closed as first, otherwise it hangs, not sure why.

Parameters
from_dvrnamename of driver from table is copied
from_dbnamename of database from table is copied
from_tbl_namename of table to be copied
to_dvrnamename of driver to - where table is copied to
to_dbnamename of database to - where table is copied to
to_dbnamename of copied table
whereWHERE SQL condition (without where key word) or NULL
selectfull select statement
selcolname of column used to select records by values in ivals or NULL
ivalspointer to array of integer values or NULL
nvalsnumber of values in ivals
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 57 of file copy_tab.c.

References _, cmp(), count, db_alloc_table(), db_append_string(), db_begin_transaction(), DB_C_TYPE_DATETIME, DB_C_TYPE_DOUBLE, DB_C_TYPE_INT, DB_C_TYPE_STRING, db_close_cursor(), db_close_database_shutdown_driver(), db_commit_transaction(), db_convert_value_to_string(), db_create_table(), db_double_quote_string(), db_drop_table(), db_execute_immediate(), DB_FAILED, db_fetch(), db_get_column_description(), db_get_column_length(), db_get_column_name(), db_get_column_precision(), db_get_column_scale(), db_get_column_sqltype(), db_get_column_value(), db_get_connection(), db_get_cursor_table(), db_get_string(), db_get_table_column(), db_get_table_number_of_columns(), db_init_handle(), db_init_string(), db_list_tables(), DB_NEXT, DB_OK, db_open_database(), db_open_select_cursor(), DB_SEQUENTIAL, db_set_column_description(), db_set_column_length(), db_set_column_name(), db_set_column_precision(), db_set_column_scale(), db_set_column_sqltype(), db_set_handle(), db_set_string(), db_set_table_name(), db_sqltype_name(), db_sqltype_to_Ctype(), db_start_driver(), db_test_value_isnull(), G_debug(), G_fatal_error(), G_free(), G_get_overwrite(), G_store(), G_strcasecmp(), G_warning(), GNAME_MAX, _db_value::i, more(), ncols, NULL, _db_connection::schemaName, and table.

Referenced by db_copy_table(), db_copy_table_by_ints(), db_copy_table_select(), and db_copy_table_where().

◆ db_copy_table()

int db_copy_table ( const char *  from_drvname,
const char *  from_dbname,
const char *  from_tblname,
const char *  to_drvname,
const char *  to_dbname,
const char *  to_tblname 
)

Copy a table.

Parameters
from_drvnamename of driver from table is copied
from_dbnamename of database from table is copied
from_tblnamename of table to be copied
to_drvnamename of driver to - where table is copied to
to_dbnamename of database to - where table is copied to
to_tblnamename of copied table
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 446 of file copy_tab.c.

References copy_table(), and NULL.

Referenced by V1_close_nat(), and Vect_rename().

◆ db_copy_table_by_ints()

int db_copy_table_by_ints ( const char *  from_drvname,
const char *  from_dbname,
const char *  from_tblname,
const char *  to_drvname,
const char *  to_dbname,
const char *  to_tblname,
const char *  selcol,
int *  ivals,
int  nvals 
)

Copy a table (by keys)

Parameters
from_drvnamename of driver from table is copied
from_dbnamename of database from table is copied
from_tblnamename of table to be copied
to_drvnamename of driver to - where table is copied to
to_dbnamename of database to - where table is copied to
to_tblnamename of copied table
selcolname of column used to select records by values in ivals or NULL
ivalspointer to array of integer values or NULL
nvalsnumber of values in ivals
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 519 of file copy_tab.c.

References copy_table(), and NULL.

Referenced by Vect_copy_table_by_cats().

◆ db_copy_table_select()

int db_copy_table_select ( const char *  from_drvname,
const char *  from_dbname,
const char *  from_tblname,
const char *  to_drvname,
const char *  to_dbname,
const char *  to_tblname,
const char *  select 
)

Copy a table (by select statement)

Parameters
from_drvnamename of driver from table is copied
from_dbnamename of database from table is copied
from_dbnamename of table to be copied
to_drvnamename of driver to - where table is copied to
to_dbnamename of database to - where table is copied to
to_tblnamename of copied table
selectfull select statement
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 493 of file copy_tab.c.

References copy_table(), and NULL.

◆ db_copy_table_where()

int db_copy_table_where ( const char *  from_drvname,
const char *  from_dbname,
const char *  from_tblname,
const char *  to_drvname,
const char *  to_dbname,
const char *  to_tblname,
const char *  where 
)

Copy a table (by where statement)

Parameters
from_drvnamename of driver from table is copied
from_dbnamename of database from table is copied
from_tblnamename of table to be copied
to_drvnamename of driver to - where table is copied to
to_dbnamename of database to - where table is copied to
to_tblnamename of copied table
whereWHERE SQL condition (without where key word)
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 469 of file copy_tab.c.

References copy_table(), and NULL.