home *** CD-ROM | disk | FTP | other *** search
- .Na "bcp_moretext"
- .mc |
- .Aa
- .Fu
- Send part of a text or image value to \*S.
- .Ih "text value, with bcp"
- .Ih "image value, with bcp"
- .Sy
- .Sf "RETCODE bcp_moretext(dbproc, size, text)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "DBINT" "size"
- .Sp "BYTE" "*text"
- .Co
- .Bl
- This routine is used in conjunction with \f2bcp_bind()\f1 and \f2bcp_sendrow()\f1
- to send a large SYBTEXT or SYBIMAGE value to \*S in the form
- of a number of smaller chunks.
- This is particularly useful with operating systems
- unable to allocate extremely long data buffers.
- .Bl
- If \f2bcp_bind()\f1 is called with a \f2type\f1 parameter of SYBTEXT or SYBIMAGE
- and a non-NULL \f2varaddr\f1 parameter, \f2bcp_sendrow()\f1 will send
- the entire text or image data value, just as it does for all other
- datatypes.
- If, however, \f2bcp_bind()\f1 has a NULL \f2varaddr\f1 parameter,
- \f2bcp_sendrow()\f1 will return control to the application immediately
- after all non-text or image columns are sent to \*S.
- The application can then call
- \f2bcp_moretext()\f1 repeatedly to send the text and image columns to \*S,
- a chunk at a time.
- .Bl
- Here's an example that illustrates how to use \f2bcp_moretext()\f1 with
- \f2bcp_bind()\f1 and \f2bcp_sendrow()\f1:
- .SD
- .ta +4n +4n +4n +4n +4n +4n
- .in +3n
- .ne 5
- LOGINREC *login;
- DBPROCESS *dbproc;
-
- DBINT id = 5;
- char *part1 = "This text value isn't very long,";
- char *part2 = " but it's broken up into three parts";
- char *part3 = " anyhow.";
-
- /* 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, "comdb..articles", (BYTE *)NULL, (BYTE *)NULL, DB_IN) == FAIL)
- exit(ERREXIT);
-
- /* Bind program variables to table columns. */
- if (bcp_bind(dbproc, (BYTE *)&id, 0, (DBINT)-1, (BYTE *)NULL, 0, SYBINT4, 1)
- == FAIL)
- {
- fprintf(stderr, "bcp_bind, column 1, failed.\en");
- exit(ERREXIT);
- }
-
- if (bcp_bind
- (dbproc, (BYTE *)NULL, 0, (DBINT) (strlen(part1) + strlen(part2) + strlen(part3)),
- (BYTE *)NULL, 0, SYBTEXT, 2)
- == FAIL)
- {
- fprintf(stderr, "bcp_bind, column 2, failed.\en");
- exit(ERREXIT);
- }
-
- /* Now send this row, with the text value broken into three chunks. */
- if (bcp_sendrow(dbproc) == FAIL)
- exit(ERREXIT);
- if (bcp_moretext(dbproc, (DBINT)strlen(part1), part1) == FAIL)
- exit(ERREXIT);
- if (bcp_moretext(dbproc, (DBINT)strlen(part2), part2) == FAIL)
- exit(ERREXIT);
- if (bcp_moretext(dbproc, (DBINT)strlen(part3), part3) == FAIL)
- exit(ERREXIT);
-
- /* We're all done. */
- bcp_done(dbproc);
- dbclose(dbproc);
- .in -3n
- .ED
- .Bl
- If you use \f2bcp_moretext()\f1 to send one text or image column in the row,
- you must also use it to send all other text and image columns in the row.
- .Bl
- If the row contains more than one text or image column,
- \f2bcp_moretext()\f1 will first send its data to the lowest-numbered (\f2i.e.,\f1
- leftmost) text or image column, followed by the next lowest-numbered
- column, and so on.
- .Bl
- An application will normally call \f2bcp_sendrow()\f1 and \f2bcp_moretext()\f1
- within loops, in order to send a number of rows of data.
- Here's an outline of how to do this for a table containing two text columns:
- .SD
- .in +3n
- .ta +4n +4n +4n +4n
- .ne 5
- while (there are still rows to send)
- {
- bcp_sendrow(...);
-
- for (all the data in the first text column)
- bcp_moretext(...);
-
- for (all the data in the second text column)
- bcp_moretext(...);
- }
- .in -3n
- .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 size
- The size of this particular part of the text or image value being sent to \*S.
- It is an error to send more text or image bytes to \*S than were specified in the
- call to \f2bcp_bind()\f1 or \f2bcp_collen()\f1.
- .Pi text
- A pointer to the text or image portion to be written.
- .in -.375i
- .Re
- .br
- SUCCEED or FAIL.
- .Sa
- bcp_bind,
- bcp_sendrow,
- dbmoretext,
- dbwritetext
- .mc
-