home *** CD-ROM | disk | FTP | other *** search
- .Na "bcp_exec"
- .mc |
- .Aa
- .Fu
- Execute a bulk copy of data between a database table and a
- host file.
- .Ih "bcp, execute a bulk copy"
- .Sy
- .Sf "RETCODE bcp_exec(dbproc, rows_copied)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "DBINT" "*rows_copied"
- .Co
- .Bl
- This routine copies data from a host file to a database
- table or vice-versa, depending on the value of the \f2direction\f1 parameter
- in \f2bcp_init()\f1.
- .Bl
- Before calling this function you must call \f2bcp_init()\f1 with a valid
- host filename. Failure to do so will result in an error.
- .Bl
- The following program fragment illustrates \f2bcp_exec()\f1:
- .SD
- .ta +4n +4n +4n +4n +4n +4n +4n
- LOGINREC *login;
- DBPROCESS *dbproc;
- DBINT rowsread;
-
- /* Initialize DB-Library. */
- 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, "pubs..authors", "authors.save", (BYTE *)NULL, DB_OUT) == FAIL)
- exit(ERREXIT);
-
- /* Now, execute the bulk copy. */
- if (bcp_exec(dbproc, &rowsread) == FAIL)
- printf("Incomplete bulk copy. Only %ld row%c copied.\en",
- rowsread, (rowsread == 1) ? ' ': 's');
- .ED
- .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 rows_copied
- A pointer to a DBINT. \f2bcp_exec()\f1 will fill this DBINT with
- the number of rows successfully copied. If set to NULL, this parameter
- will not be filled in by \f2bcp_exec()\f1.
- .in -.375i
- .Re
- .br
- SUCCEED or FAIL. \f2bcp_exec()\f1 returns SUCCEED if all rows are
- copied. If a partial or complete failure occurs, \f2bcp_exec()\f1 returns
- FAIL. Check the \f2rows_copied\f1 parameter for the number of rows
- successfully copied.
- .Sa
- bcp_batch,
- bcp_bind,
- bcp_colfmt,
- bcp_collen,
- bcp_colptr,
- bcp_columns,
- bcp_control,
- bcp_done,
- bcp_init,
- bcp_sendrow
- .mc
-