home *** CD-ROM | disk | FTP | other *** search
- .Na "bcp_init"
- .mc |
- .Aa
- .Fu
- Initialize bulk copy.
- .Ih "bcp, initialize bulk copy"
- .Ih "bulk copy, initialize"
- .Ih "copy, bulk"
- .Sy
- .Sf "RETCODE bcp_init(dbproc, tblname, hfile, errfile, direction)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "char" "*tblname"
- .Sp "char" "*hfile"
- .Sp "char" "*errfile"
- .Sp "int" "direction"
- .Co
- .Bl
- \f2bcp_init()\f1 performs the necessary initializations for a bulk
- copy of data between the front-end and a \*S. It sets
- the default host file data formats and examines the structure
- of the database table.
- .Bl
- If a host file is being used (see the description of the \f2hfile\f1 parameter, below),
- .Ih "bcp, default data formats"
- the default data formats are as follows:
- .in +5n
- .Bl *
- 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.
- .Bl *
- 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 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.
- .Bl *
- There are no terminators of any kind between host file
- columns.
- .in -5n
- .sp 0.5v
- Any of these defaults can be overridden by calling \f2bcp_columns()\f1
- and \f2bcp_colfmt().\f1
- .Bl
- To use the bulk copy routines to copy data to a
- database table requires the following:
- .in +5n
- .Bl *
- The DBPROCESS structure must be usable for bulk copy
- purposes. This is accomplished by calling \f2BCP_SETL():\f1
- .SD
- .in +3n
- login = dblogin();
- BCP_SETL(login, TRUE);
- .in -3n
- .ED
- .Bl *
- If the table has no indexes,
- the database option \f2select into/bulkcopy\f1 must be set to ``true''.
- The following SQL command will do this:
- .SD
- .in +3n
- sp_dboption 'mydb', 'select into/bulkcopy', 'true'
- .in -3n
- .ED
- See the \f2Commands Reference\f1 for further details on \f2sp_dboption\f1.
- .in -5n
- .Bl
- If no host file is being used, it's necessary to call \f2bcp_bind()\f1
- to specify the format and location in memory of each column's data value.
- .Bl
- \f2bcp_init()\f1 must be called before any other bulk copy
- functions. Failure to do so will result in an error.
- .Bl
- For information on the \f2bcp\f1 utility program, see its manual page
- in the \f2Commands Reference\f1.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .Pi 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.
- .Pi 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), \f2hfile\f1 should be NULL.
- .Pi 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 \*S table.
- If NULL is passed as \f2errfile\f1, no error file will be used.
- .Pi direction
- The direction of the copy. It must be one of two
- values\(emDB_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.
- .sp 0.5v
- It is illegal to request a bulk copy from the
- database table (DB_OUT) without supplying a host file name.
- .in -.375i
- .Re
- .br
- SUCCEED or FAIL.
- .Sa
- bcp_batch,
- bcp_bind,
- bcp_colfmt,
- bcp_collen,
- bcp_colptr,
- bcp_columns,
- bcp_control,
- bcp_done,
- bcp_exec,
- bcp_sendrow
- .mc
-