|
FreeTDS API
|
Functions to bulk-copy (a/k/a bcp) data to/from the database. More...
Modules | |
| Internal bcp functions | |
| Static functions internal to the bcp library. | |
Functions | |
| DBINT | bcp_batch (DBPROCESS *dbproc) |
| Commit a set of rows to the table. More... | |
| RETCODE | bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column) |
| Bind a program host variable to a database column. More... | |
| 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. More... | |
| 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. More... | |
| RETCODE | bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column) |
| Set the length of a host variable to be written to a table. More... | |
| RETCODE | bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column) |
| Override bcp_bind() by pointing to a different host variable. More... | |
| RETCODE | bcp_columns (DBPROCESS *dbproc, int host_colcount) |
| Indicate how many columns are to be found in the datafile. More... | |
| RETCODE | bcp_control (DBPROCESS *dbproc, int field, DBINT value) |
| Set BCP options for uploading a datafile. More... | |
| DBINT | bcp_done (DBPROCESS *dbproc) |
| Conclude the transfer of data from program variables. More... | |
| RETCODE | bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied) |
| Write a datafile to a table. More... | |
| DBBOOL | bcp_getl (LOGINREC *login) |
| See if BCP_SETL() was used to set the LOGINREC for BCP work. More... | |
| RETCODE | bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction) |
| Prepare for bulk copy operation on a table. More... | |
| RETCODE | bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen) |
| Set "hints" for uploading a file. More... | |
| RETCODE | bcp_readfmt (DBPROCESS *dbproc, const char filename[]) |
| Read a format definition file. More... | |
| RETCODE | bcp_sendrow (DBPROCESS *dbproc) |
| Write data in host variables to the table. More... | |
Functions to bulk-copy (a/k/a bcp) data to/from the database.
| DBINT bcp_batch | ( | DBPROCESS * | dbproc | ) |
Commit a set of rows to the table.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| RETCODE bcp_bind | ( | DBPROCESS * | dbproc, |
| BYTE * | varaddr, | ||
| int | prefixlen, | ||
| DBINT | varlen, | ||
| BYTE * | terminator, | ||
| int | termlen, | ||
| int | db_vartype, | ||
| int | table_column | ||
| ) |
Bind a program host variable to a database column.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| varaddr | address of host variable |
| prefixlen | length of any prefix found at the beginning of varaddr, in bytes. Use zero for fixed-length datatypes. |
| varlen | bytes of data in varaddr. Zero for NULL, -1 for fixed-length datatypes. |
| terminator | byte sequence that marks the end of the data in varaddr |
| termlen | length of terminator |
| vartype | datatype of the host variable |
| table_column | Nth column, starting at 1, in the table. |
| 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.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| host_colnum | datafile column number (starting with 1, not zero). |
| host_type | dataype token describing the data type in host_colnum. E.g. SYBCHAR for character data. |
| host_prefixlen | size of the prefix in the datafile column, if any. For delimited files: zero. May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the data file, and will be interpreted the data size of that column, in bytes. |
| host_collen | maximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. Special values:
|
| host_term | the sequence of characters that will serve as a column terminator (delimiter) in the datafile. Often a tab character, but can be any string of any length. Zero indicates no terminator. Special characters:
|
| host_termlen | the length of host_term, in bytes. |
| table_colnum | Nth column, starting at 1, in the table that maps to host_colnum. If there is a column in the datafile that does not map to a table column, set table_colnum to zero. |
When a prefix or terminator is used with variable-length data, host_collen may have one of three values:
| 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.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| host_colnum | datafile column number (starting with 1, not zero). |
| host_type | dataype token describing the data type in host_colnum. E.g. SYBCHAR for character data. |
| host_prefixlen | size of the prefix in the datafile column, if any. For delimited files: zero. May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the data file, and will be interpreted the data size of that column, in bytes. |
| host_collen | maximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. Special values:
|
| host_term | the sequence of characters that will serve as a column terminator (delimiter) in the datafile. Often a tab character, but can be any string of any length. Zero indicates no terminator. Special characters:
|
| host_termlen | the length of host_term, in bytes. |
| table_colnum | Nth column, starting at 1, in the table that maps to host_colnum. If there is a column in the datafile that does not map to a table column, set table_colnum to zero. |
| typeinfo | something |
| RETCODE bcp_collen | ( | DBPROCESS * | dbproc, |
| DBINT | varlen, | ||
| int | table_column | ||
| ) |
Set the length of a host variable to be written to a table.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| varlen | size of the variable, in bytes, or
|
| table_column | the number of the column in the table (starting with 1, not zero). |
| RETCODE bcp_colptr | ( | DBPROCESS * | dbproc, |
| BYTE * | colptr, | ||
| int | table_column | ||
| ) |
Override bcp_bind() by pointing to a different host variable.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| colptr | The pointer, the address of your variable. |
| table_column | The 1-based column ordinal in the table. |
| RETCODE bcp_columns | ( | DBPROCESS * | dbproc, |
| int | host_colcount | ||
| ) |
Indicate how many columns are to be found in the datafile.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| host_colcount | count of columns in the datafile, irrespective of how many you intend to use. |
| RETCODE bcp_control | ( | DBPROCESS * | dbproc, |
| int | field, | ||
| DBINT | value | ||
| ) |
Set BCP options for uploading a datafile.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| field | symbolic constant indicating the option to be set, one of:
|
| value | The value for field. |
| DBINT bcp_done | ( | DBPROCESS * | dbproc | ) |
Conclude the transfer of data from program variables.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| RETCODE bcp_exec | ( | DBPROCESS * | dbproc, |
| DBINT * | rows_copied | ||
| ) |
Write a datafile to a table.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| rows_copied | bcp_exec will write the count of rows successfully written to this address. If rows_copied is NULL, it will be ignored by db-lib. |
| 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.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| tblname | the name of the table receiving or providing the data. |
| hfile | the data file opposite the table, if any. |
| errfile | the "error file" captures messages and, if errors are encountered, copies of any rows that could not be written to the table. |
| direction | one of
|
When writing to a table, bcp can use as its data source a data file (hfile), or program data in an application's variables. In the latter case, call bcp_bind() to associate your data with the appropriate table column.
| RETCODE bcp_options | ( | DBPROCESS * | dbproc, |
| int | option, | ||
| BYTE * | value, | ||
| int | valuelen | ||
| ) |
Set "hints" for uploading a file.
A FreeTDS-only function.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| option | symbolic constant indicating the option to be set, one of:
|
| value | The string constant for option a/k/a the hint. One of:
|
| valuelen | The strlen of value. |
| RETCODE bcp_readfmt | ( | DBPROCESS * | dbproc, |
| const char | filename[] | ||
| ) |
Read a format definition file.
| dbproc | contains all information needed by db-lib to manage communications with the server. |
| filename | Name that will be passed to fopen(3). |
| RETCODE bcp_sendrow | ( | DBPROCESS * | dbproc | ) |
Write data in host variables to the table.
| dbproc | contains all information needed by db-lib to manage communications with the server. |