home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / usr / sybase / doc / bcp_control.man < prev    next >
Encoding:
Text File  |  1993-04-22  |  4.7 KB  |  155 lines

  1.  
  2.   1                       Version 4.0 -- 5/1/89              bcp_control
  3.   ______________________________________________________________________
  4.  
  5.   NAME:  bcp_control
  6.  
  7.   FUNCTION:
  8.        Change various control parameter default settings.
  9.  
  10.   SYNTAX:
  11.        RETCODE bcp_control(dbproc, field, value)
  12.  
  13.        DBPROCESS *dbproc;
  14.        int       field;
  15.        DBINT     value;
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.   bcp_control             Version 4.0 -- 5/1/89                        2
  25.   ______________________________________________________________________
  26.  
  27.   COMMENTS:
  28.  
  29.        o This function sets various control  parameters  for  bulk  copy
  30.          operations,  including  the  number  of  errors  allowed before
  31.          aborting a bulk copy, the numbers of the first and last rows to
  32.          copy, and the batch size.
  33.        o These control  parameters  are  only  meaningful  when  copying
  34.          between  a host file and a SQL Server table.  Control parameter
  35.          settings have no effect on bcp_bind() row transfers.
  36.  
  37.        o The following program fragment illustrates bcp_control():
  38.  
  39.          LOGINREC        *login;
  40.          DBPROCESS       *dbproc;
  41.          DBINT           rowsread;
  42.  
  43.          /* Initialize DB-Library. */
  44.  
  45.  
  46.   3                       Version 4.0 -- 5/1/89              bcp_control
  47.   ______________________________________________________________________
  48.          if (dbinit() == FAIL)
  49.              exit(ERREXIT);
  50.  
  51.          /* Install error-handler and message-handler. */
  52.          dberrhandle(err_handler);
  53.          dbmsghandle(msg_handler);
  54.  
  55.          /* Open a DBPROCESS. */
  56.          login = dblogin();
  57.          BCP_SETL(login, TRUE);
  58.          dbproc = dbopen(login, NULL);
  59.  
  60.          /* Initialize bcp. */
  61.          if (bcp_init(dbproc, "comdb..address", "address.add", "addr.error", DB_IN) == FAIL)
  62.              exit(ERREXIT);
  63.  
  64.          /* Set the number of rows per batch. */
  65.  
  66.  
  67.  
  68.   bcp_control             Version 4.0 -- 5/1/89                        4
  69.   ______________________________________________________________________
  70.          if (bcp_control(dbproc, BCPBATCH, 1000) == FAIL)
  71.          {
  72.              printf("bcp_control failed to set batching behavior.\n");
  73.              exit(ERREXIT);
  74.          }
  75.  
  76.          /* Set host column count. */
  77.          if (bcp_columns(dbproc, 1) == FAIL)
  78.          {
  79.              printf("bcp_columns failed.\n");
  80.              exit(ERREXIT);
  81.          }
  82.  
  83.          /* Set the host-file format. */
  84.          if (bcp_colfmt(dbproc, 1, 0, 0, -1, (BYTE *)("\n"), 1, 1) == FAIL)
  85.          {
  86.              printf("bcp_colformat failed.\n");
  87.  
  88.  
  89.  
  90.   5                       Version 4.0 -- 5/1/89              bcp_control
  91.   ______________________________________________________________________
  92.              exit(ERREXIT);
  93.          }
  94.  
  95.          /* Now, execute the bulk copy. */
  96.          if (bcp_exec(dbproc, &rowsread) == FAIL)
  97.          {
  98.              printf("Incomplete bulk copy.  Only %ld row%c copied.\n",
  99.                      rowsread, (rowsread == 1) ? ' ': 's');
  100.  
  101.              exit(ERREXIT);
  102.          }
  103.  
  104.  
  105.        o For information on the bcp utility program, see its manual page
  106.          in the Commands Reference.
  107.  
  108.   PARAMETERS:
  109.        dbproc -  A pointer to the DBPROCESS structure that provides  the
  110.  
  111.  
  112.   bcp_control             Version 4.0 -- 5/1/89                        6
  113.   ______________________________________________________________________
  114.            connection for a particular front-end/SQL Server process.  It
  115.            contains  all  the information that DB-Library uses to manage
  116.            communications and data between the front end and SQL Server.
  117.        field -  The field can be one of the following:
  118.  
  119.               Field         Description
  120.               BCPMAXERRS    The number of errors allowed before giving up.  The
  121.                             default is 10.
  122.  
  123.               BCPFIRST      The first row to copy. The default is 1.  A value of
  124.                             less than 1 resets this field to its default value of 1.
  125.  
  126.               BCPLAST       The last row to copy. The default is to copy all rows.
  127.                             A value less than 1 resets this field to its default value.
  128.  
  129.               BCPBATCH      The number of rows per batch. The default is 0, which
  130.                             means that the entire bulk copy will be done in one
  131.  
  132.  
  133.  
  134.   7                       Version 4.0 -- 5/1/89              bcp_control
  135.   ______________________________________________________________________
  136.                             batch.  This field is only meaningful when copying from
  137.                             a host file into SQL Server.
  138.  
  139.        value -  The value for the specified field.
  140.  
  141.   RETURNS:
  142.        SUCCEED or FAIL.
  143.  
  144.   SEE ALSO:
  145.        bcp_batch,   bcp_bind,   bcp_colfmt,   bcp_collen,    bcp_colptr,
  146.        bcp_columns, bcp_done, bcp_exec, bcp_init
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.