home *** CD-ROM | disk | FTP | other *** search
-
- 1 Version 4.0 -- 5/1/89 bcp_init
- ______________________________________________________________________
-
- NAME: bcp_init
-
- FUNCTION:
- Initialize bulk copy.
-
- SYNTAX:
- RETCODE bcp_init(dbproc, tblname, hfile, errfile, direction)
-
- DBPROCESS *dbproc;
- char *tblname;
- char *hfile;
- char *errfile;
-
-
-
-
-
-
-
- bcp_init Version 4.0 -- 5/1/89 2
- ______________________________________________________________________
- int direction;
-
- COMMENTS:
-
- o bcp_init() performs the necessary initializations for a bulk
- copy of data between the front-end and a SQL Server. It sets
- the default host file data formats and examines the structure
- of the database table.
- o If a host file is being used (see the description of the hfile
- parameter, below), the default data formats are as follows:
-
- o The order, type, length and number of the columns in the
- host file are assumed to be identical to the order, type
- and number of the columns in the database table.
- o If a given database column's data is fixed-length, then
- the host file's data column will also be fixed-length. If
- a given database column's data is variable-length or may
-
-
-
- 3 Version 4.0 -- 5/1/89 bcp_init
- ______________________________________________________________________
- contain NULL values, the host file's data column will be
- prefixed by a 4-byte length value for SYBTEXT and SYBIMAGE
- data types, and a 1-byte length value for all other types.
-
- o There are no terminators of any kind between host file
- columns.
- Any of these defaults can be overridden by calling
- bcp_columns() and bcp_colfmt().
-
- o To use the bulk copy routines to copy data to a database table
- requires the following:
- o The DBPROCESS structure must be usable for bulk copy pur-
- poses. This is accomplished by calling BCP_SETL():
-
- login = dblogin();
- BCP_SETL(login, TRUE);
-
-
-
-
- bcp_init Version 4.0 -- 5/1/89 4
- ______________________________________________________________________
-
- o If the table has no indexes, the database option select
- into/bulkcopy must be set to "true". The following SQL
- command will do this:
-
- sp_dboption 'mydb', 'select into/bulkcopy', 'true'
-
- See the Commands Reference for further details on
- sp_dboption.
- o If no host file is being used, it's necessary to call
- bcp_bind() to specify the format and location in memory of each
- column's data value.
-
- o bcp_init() must be called before any other bulk copy functions.
- Failure to do so will result in an error.
- o For information on the bcp utility program, see its manual page
- in the Commands Reference.
-
-
-
- 5 Version 4.0 -- 5/1/89 bcp_init
- ______________________________________________________________________
-
- PARAMETERS:
- dbproc - A pointer to the DBPROCESS structure that provides the
- connection for a particular front-end/SQL Server process. It
- contains all the information that DB-Library uses to manage
- communications and data between the front end and SQL Server.
- tblname - The name of the database table to be copied in or out.
- This name may also include the database name or the owner
- name. For example, "pubs.gracie.titles", "pubs..titles",
- "gracie.titles", and "titles" are all legal table names.
- hfile - The name of the host file to be copied in or out. If no
- host file is involved (the situation when data is being
- copied directly from variables), hfile should be NULL.
- errfile - The name of the error file to be used. This error file
- will be filled with progress messages, error messages, and
- copies of any rows which, for any reason, could not be copied
- from a host file to a SQL Server table. If NULL is passed as
-
-
-
- bcp_init Version 4.0 -- 5/1/89 6
- ______________________________________________________________________
- errfile, no error file will be used.
- direction - The direction of the copy. It must be one of two
- values-DB_IN or DB_OUT. DB_IN indicates a copy from the host
- into the database table, while DB_OUT indicates a copy from
- the database table into the host file.
-
- It is illegal to request a bulk copy from the database table
- (DB_OUT) without supplying a host file name.
-
- RETURNS:
- SUCCEED or FAIL.
-
- SEE ALSO:
- bcp_batch, bcp_bind, bcp_colfmt, bcp_collen, bcp_colptr,
- bcp_columns, bcp_control, bcp_done, bcp_exec, bcp_sendrow
-
-
-
-
-