Microsoft KB Archive/180781

= INF: How to Use DBBCMD to Enable BCP IN Through an ODS Gateway Application =

Article ID: 180781

Article Last Modified on 10/3/2003

-

APPLIES TO


 * Microsoft SQL Server 6.5 Standard Edition

-



This article was previously published under Q180781



SUMMARY
This article discusses the use of dbbcmd to enable the use of the Bulk Copy Program (BCP) to use BCP IN functionality through an Open Data Services application.



MORE INFORMATION
A BCP OUT operation through a gateway is already supported. The BCP OUT is simply a SELECT operation that the gateway supports. However, the BCP IN operation is a special operation, and therefore requires the use of dbbcmd. To do this, perform the following steps:

  Use the following command to expose the dbbcmd function:

extern "C" RETCODE SQLAPI dbbcmd(DBPROCESS *, CHAR *, ...);  When the client connects, check for and properly enable BCP with a call to BCP_SETL.  BCP operations are handled in the lang_exec event. The start of a BCP operation is signaled by "insert bulk". Check the srv_langptr for this string. Consider the following example:

char * strCmd = (char *)srv_langptr(psrvProc); if(0 == strncmp((char *)strCmd, "insert bulk", 11)) ..

 Submit the "insert bulk" command to the SQL Server with the dbcmd call.  The next lang_exec event from the client should be submitted with the dbbcmd call, as in the following example:

int iLen = srv_langlen(psrvProc);

if(iLen == -1L) iLen = 0L;

rc = dbbcmd(pdbProc, strCmd, iLen);

..

 Process results normally. See the handle_results function in the ODS</ol>

gateway sample for complete details.

The pattern of "insert bulk" and a binary packet requiring alternating calls to dbcmd and dbbcmd can occur many times in single BCP session. The smaller the BCP batch size, the more often the combination will need to be processed.

NOTE: Remember that you are adding another layer of indirection, so you may not yield the same BCP performance statistics you might achieve by directly bulk copying the data into the SQL Server.

Additional query words: procsrv ods

Keywords: kbhowto kbinfo KB180781

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.