1 Version 4.0 -- 5/1/89 bcp_control
______________________________________________________________________
NAME: bcp_control
FUNCTION:
Change various control parameter default settings.
SYNTAX:
RETCODE bcp_control(dbproc, field, value)
DBPROCESS *dbproc;
int field;
DBINT value;
bcp_control Version 4.0 -- 5/1/89 2
______________________________________________________________________
COMMENTS:
o This function sets various control parameters for bulk copy
operations, including the number of errors allowed before
aborting a bulk copy, the numbers of the first and last rows to
copy, and the batch size.
o These control parameters are only meaningful when copying
between a host file and a SQL Server table. Control parameter
settings have no effect on bcp_bind() row transfers.
o The following program fragment illustrates bcp_control():
LOGINREC *login;
DBPROCESS *dbproc;
DBINT rowsread;
/* Initialize DB-Library. */
3 Version 4.0 -- 5/1/89 bcp_control
______________________________________________________________________
if (dbinit() == FAIL)
exit(ERREXIT);
/* Install error-handler and message-handler. */
dberrhandle(err_handler);
dbmsghandle(msg_handler);
/* Open a DBPROCESS. */
login = dblogin();
BCP_SETL(login, TRUE);
dbproc = dbopen(login, NULL);
/* Initialize bcp. */
if (bcp_init(dbproc, "comdb..address", "address.add", "addr.error", DB_IN) == FAIL)
exit(ERREXIT);
/* Set the number of rows per batch. */
bcp_control Version 4.0 -- 5/1/89 4
______________________________________________________________________
if (bcp_control(dbproc, BCPBATCH, 1000) == FAIL)
{
printf("bcp_control failed to set batching behavior.\n");
exit(ERREXIT);
}
/* Set host column count. */
if (bcp_columns(dbproc, 1) == FAIL)
{
printf("bcp_columns failed.\n");
exit(ERREXIT);
}
/* Set the host-file format. */
if (bcp_colfmt(dbproc, 1, 0, 0, -1, (BYTE *)("\n"), 1, 1) == FAIL)
{
printf("bcp_colformat failed.\n");
5 Version 4.0 -- 5/1/89 bcp_control
______________________________________________________________________
exit(ERREXIT);
}
/* Now, execute the bulk copy. */
if (bcp_exec(dbproc, &rowsread) == FAIL)
{
printf("Incomplete bulk copy. Only %ld row%c copied.\n",
rowsread, (rowsread == 1) ? ' ': 's');
exit(ERREXIT);
}
o For information on the bcp utility program, see its manual page
in the Commands Reference.
PARAMETERS:
dbproc - A pointer to the DBPROCESS structure that provides the
bcp_control Version 4.0 -- 5/1/89 6
______________________________________________________________________
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.
field - The field can be one of the following:
Field Description
BCPMAXERRS The number of errors allowed before giving up. The
default is 10.
BCPFIRST The first row to copy. The default is 1. A value of
less than 1 resets this field to its default value of 1.
BCPLAST The last row to copy. The default is to copy all rows.
A value less than 1 resets this field to its default value.
BCPBATCH The number of rows per batch. The default is 0, which
means that the entire bulk copy will be done in one
7 Version 4.0 -- 5/1/89 bcp_control
______________________________________________________________________
batch. This field is only meaningful when copying from
a host file into SQL Server.
value - The value for the specified field.
RETURNS:
SUCCEED or FAIL.
SEE ALSO:
bcp_batch, bcp_bind, bcp_colfmt, bcp_collen, bcp_colptr,
bcp_columns, bcp_done, bcp_exec, bcp_init