home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextLibrary / Documentation / Sybase / DBLIB / Section3 / bcp_exec.nr < prev    next >
Encoding:
Text File  |  1993-04-22  |  2.1 KB  |  83 lines

  1. .Na "bcp_exec"
  2. .mc |
  3. .Aa
  4. .Fu
  5. Execute a bulk copy of data between a database table and a
  6. host file.
  7. .Ih "bcp, execute a bulk copy"
  8. .Sy
  9. .Sf "RETCODE bcp_exec(dbproc, rows_copied)"
  10. .Sp "DBPROCESS" "*dbproc"
  11. .Sp "DBINT" "*rows_copied"
  12. .Co
  13. .Bl
  14. This routine copies data from a host file to a database
  15. table or vice-versa, depending on the value of the \f2direction\f1 parameter
  16. in \f2bcp_init()\f1.
  17. .Bl
  18. Before calling this function you must call \f2bcp_init()\f1 with a valid
  19. host filename. Failure to do so will result in an error.
  20. .Bl
  21. The following program fragment illustrates \f2bcp_exec()\f1:
  22. .SD
  23. .ta +4n +4n +4n +4n +4n +4n +4n
  24. LOGINREC        *login;
  25. DBPROCESS       *dbproc;
  26. DBINT           rowsread;
  27.  
  28. /* Initialize DB-Library. */
  29. if (dbinit() == FAIL)
  30.     exit(ERREXIT);
  31.  
  32. /* Install error-handler and message-handler. */
  33. dberrhandle(err_handler);
  34. dbmsghandle(msg_handler);
  35.  
  36. /* Open a DBPROCESS. */
  37. login = dblogin();
  38. BCP_SETL(login, TRUE);
  39. dbproc = dbopen(login, NULL);
  40.  
  41. /* Initialize bcp. */
  42. if (bcp_init(dbproc, "pubs..authors", "authors.save", (BYTE *)NULL, DB_OUT) == FAIL)
  43.     exit(ERREXIT);
  44.  
  45. /* Now, execute the bulk copy. */
  46. if (bcp_exec(dbproc, &rowsread) == FAIL)
  47.     printf("Incomplete bulk copy.  Only %ld row%c copied.\en",
  48.             rowsread, (rowsread == 1) ? ' ': 's');
  49. .ED
  50. .Bl
  51. For information on the \f2bcp\f1 utility program, see its manual page
  52. in the \f2Commands Reference\f1.
  53. .Bz
  54. .Pa
  55. .Pi dbproc
  56. A pointer to the DBPROCESS structure that provides the connection
  57. for a particular front-end/\*S process.  It contains all the
  58. information that \*L uses to manage communications and data between the
  59. front end and \*S.
  60. .Pi rows_copied
  61. A pointer to a DBINT. \f2bcp_exec()\f1 will fill this DBINT with
  62. the number of rows successfully copied. If set to NULL, this parameter
  63. will not be filled in by \f2bcp_exec()\f1.
  64. .in -.375i
  65. .Re
  66. .br
  67. SUCCEED or FAIL. \f2bcp_exec()\f1 returns SUCCEED if all rows are
  68. copied. If a partial or complete failure occurs, \f2bcp_exec()\f1 returns
  69. FAIL. Check the \f2rows_copied\f1 parameter for the number of rows
  70. successfully copied.
  71. .Sa
  72. bcp_batch,
  73. bcp_bind,
  74. bcp_colfmt,
  75. bcp_collen,
  76. bcp_colptr,
  77. bcp_columns,
  78. bcp_control,
  79. bcp_done,
  80. bcp_init,
  81. bcp_sendrow
  82. .mc
  83.