Executes a complete bulk copy of data between a database table and a user file.
RETCODE bcp_exec (
PDBPROCESS dbproc,
LPDBINT rows_copied );
where
SUCCEED or FAIL. The bcp_exec function returns SUCCEED if all rows are copied. If a partial or complete failure occurs, bcp_exec returns FAIL. Check the rows_copied parameter for the number of rows successfully copied.
This function copies data from a user file to a database table or vice versa, depending on the value of the direction parameter in bcp_init.
Before calling bcp_exec, call bcp_init with a valid user filename. Failure to do so results in an error.
The following example shows how to use bcp_exec:
LOGINREC *login; DBPROCESS *dbproc; DBINT rowsread; // Install error-handler and message-handler. dberrhandle(err_handler); dbmsghandle(msg_handler); // Open a DBPROCESS. login = dblogin(); DBSETLUSER(login, "user"); DBSETLPWD(login, "my_passwd"); DBSETLAPP(login, "example"); BCP_SETL(login, TRUE); dbproc = dbopen(login, "my_server"); // Initialize bcp. if (bcp_init(dbproc, "pubs..authors", "authors.sav", (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%s copied.\n", rowsread, (rowsread == 1) ? "": "s");
bcp_batch, bcp_bind, bcp_colfmt, bcp_collen, bcp_colptr, bcp_columns, bcp_control, bcp_done, bcp_init, bcp_sendrow