Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Sybase DB Library C 4.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

  1                       Version 4.0 -- 5/1/89                 bcp_exec
  ______________________________________________________________________

  NAME:  bcp_exec

  FUNCTION:
       Execute a bulk copy of data between a database table and  a  host
       file.

  SYNTAX:
       RETCODE bcp_exec(dbproc, rows_copied)

       DBPROCESS *dbproc;
       DBINT     *rows_copied;








  bcp_exec                Version 4.0 -- 5/1/89                        2
  ______________________________________________________________________

  COMMENTS:

       o This routine copies data from a host file to a  database  table
         or  vice-versa, depending on the value of the direction parame-
         ter in bcp_init().
       o Before calling this function you must call  bcp_init()  with  a
         valid host filename. Failure to do so will result in an error.

       o The following program fragment illustrates bcp_exec():

         LOGINREC        *login;
         DBPROCESS       *dbproc;
         DBINT           rowsread;

         /* Initialize DB-Library. */
         if (dbinit() == FAIL)
             exit(ERREXIT);


  3                       Version 4.0 -- 5/1/89                 bcp_exec
  ______________________________________________________________________

         /* 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.\n",



  bcp_exec                Version 4.0 -- 5/1/89                        4
  ______________________________________________________________________
                     rowsread, (rowsread == 1) ? ' ': 's');


       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
           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.
       rows_copied -  A pointer to a DBINT. bcp_exec()  will  fill  this
           DBINT  with the number of rows successfully copied. If set to
           NULL, this parameter will not be filled in by bcp_exec().

  RETURNS:
       SUCCEED or FAIL. bcp_exec()  returns  SUCCEED  if  all  rows  are
       copied.  If  a  partial  or  complete  failure occurs, bcp_exec()


  5                       Version 4.0 -- 5/1/89                 bcp_exec
  ______________________________________________________________________
       returns FAIL. Check the rows_copied parameter for the  number  of
       rows successfully copied.

  SEE ALSO:
       bcp_batch,   bcp_bind,   bcp_colfmt,   bcp_collen,    bcp_colptr,
       bcp_columns, bcp_control, bcp_done, bcp_init, bcp_sendrow













Typewritten Software • bear@typewritten.org • Edmonds, WA 98026