Skip to Content.
Sympa Menu

freetds - Re: [freetds] RETCODE conflict and ODBC/bcp bridge

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Frederick N. Brier" <multideck AT comcast.net>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] RETCODE conflict and ODBC/bcp bridge
  • Date: Fri, 01 Apr 2005 20:47:10 -0500

Just wanted to let you know I got it working. I used Freddy's trick with the define/undef. I had to put an ifdef RETCODE around the typedef because it was complaining of defining an int to an int. Had to do that with BOOL as well. It also turns out that the valid parameters in a bcp_bind (beyond the first one being a DBPROCESS *) are different between Microsoft's and Sybase's/FreeTDS's. I had to put ifdef(s) round those 2 in my BulkInsert class to stuff in the different parameters, but the unit test works. I had a weird issue with not being able to make odbc_errs_reset() a public symbol - not sure why. Now it needs to pass tests incorporated into the Linux version of our product.

Is this ODBC bcp functionality something that would be useful put back into the FreeTDS code base? It would need more work to flesh it out and move it into "C" functions, cause I jammed the create DBPROCESS into a method inside my BulkInsert class. Thank you for all of your help.

Fred.

James K. Lowden wrote:

"Frederick N. Brier" <multideck AT comcast.net> wrote:

Does #undef work on a typedef? I would have thought #undef is a symbol in the preprocessor and typedef is a symbol in the compiler's symbol table.

You are correct. Freddy's code:


#include <sql.h>
#define RETCODE DBRETCODE
#include <sybdb.h>
#undef RETCODE

DBRETCODE ret; // dblib return code
RETCODE rc; // ODBC return code


effectively replaces all RETCODE references in sybdb.h with DBRETCODE,
allowing the .c file to use DBRETCODE for functions declared in sybdb.h,
and RETCODE for functions declared in sql.h.

What I am trying to do is call bcp_* routines in the dblib using an ODBC connection. The approach is put together a DBPROCESS struct from the various TDS structs pointed to by the ODBC based structs since both dblib/bcp* functions in the dblib as well as the ODBC library are built on the same underlying TDS structs and methods.

Novel, interesting, tricky, and might work. Each library maintains its
own state information, so if you're going to mix ODBC and db-lib functions
on the same connection, you have to be very careful at the application
level to do what the server expects. Be advised that if you make a
protocol error, very often the server's response will be simply to drop
the connection.
That said, as long as you clearly segregate the bcp work from the ODBC
querying, I can't think of any reason it wouldn't work, or couldn't be
made to.
--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds








  • Re: [freetds] RETCODE conflict and ODBC/bcp bridge, Frederick N. Brier, 04/01/2005

Archive powered by MHonArc 2.6.24.

Top of Page