/home/jklowden/releases/freetds-0.91/src/dblib/bcp.c File Reference

Implementation of db-lib bulk copy functions. More...

#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <tds.h>
#include <tdsiconv.h>
#include <tdsconvert.h>
#include <replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>

Defines

#define fseeko(f, o, w)   fseek(f,o,w)
#define ftello(f)   ftell(f)
#define HOST_COL_CONV_ERROR   1
#define HOST_COL_NULL_ERROR   2
#define MAX(a, b)   ( (a) > (b) ? (a) : (b) )

Typedefs

typedef long offset_type

Functions

static RETCODE _bcp_check_eof (DBPROCESS *dbproc, FILE *file, int icol)
static RETCODE _bcp_exec_in (DBPROCESS *dbproc, DBINT *rows_copied)
static RETCODE _bcp_exec_out (DBPROCESS *dbproc, DBINT *rows_copied)
static char * _bcp_fgets (char *buffer, int size, FILE *f)
static void _bcp_free_columns (DBPROCESS *dbproc)
static void _bcp_free_storage (DBPROCESS *dbproc)
static int _bcp_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
 For a bcp in from program variables, get the data from the host variable.
static int _bcp_get_term_var (BYTE *pdata, BYTE *term, int term_len)
 Get the data for bcp-in from program variables, where the program data have been identified as character terminated, This is a low-level, internal function.
static offset_type _bcp_measure_terminated_field (FILE *hostfile, BYTE *terminator, int term_len)
static int _bcp_no_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
static void _bcp_null_error (TDSBCPINFO *bcpinfo, int index, int offset)
static RETCODE _bcp_read_hostfile (DBPROCESS *dbproc, FILE *hostfile, int *row_error)
static int _bcp_readfmt_colinfo (DBPROCESS *dbproc, char *buf, BCP_HOSTCOLINFO *ci)
DBINT bcp_batch (DBPROCESS *dbproc)
 Commit a set of rows to the table.
RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int vartype, int table_column)
 Bind a program host variable to a database column.
RETCODE bcp_colfmt (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int table_colnum)
 Specify the format of a datafile prior to writing to a table.
RETCODE bcp_colfmt_ps (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo)
 Specify the format of a host file for bulk copy purposes, with precision and scale support for numeric and decimal columns.
RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
 Set the length of a host variable to be written to a table.
RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
 Override bcp_bind() by pointing to a different host variable.
RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
 Indicate how many columns are to be found in the datafile.
RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
 Set BCP options for uploading a datafile.
DBINT bcp_done (DBPROCESS *dbproc)
 Conclude the transfer of data from program variables.
RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
 Write a datafile to a table.
int bcp_getbatchsize (DBPROCESS *dbproc)
DBBOOL bcp_getl (LOGINREC *login)
 See if BCP_SETL() was used to set the LOGINREC for BCP work.
RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
 Prepare for bulk copy operation on a table.
RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
 Set "hints" for uploading a file.
RETCODE bcp_readfmt (DBPROCESS *dbproc, const char filename[])
 Read a format definition file.
RETCODE bcp_sendrow (DBPROCESS *dbproc)
 Write data in host variables to the table.
static void init_hostfile_columns (DBPROCESS *dbproc)
static int rtrim (char *str, int len)
 trim a string of trailing blanks
 TDS_RCSID (var,"$Id: bcp.c,v 1.197.2.8 2011/06/07 08:52:29 freddy77 Exp $")

Detailed Description

Implementation of db-lib bulk copy functions.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Wed Aug 17 22:22:31 2011 for FreeTDS API by  doxygen 1.6.3