Oh my ODBC 38

Apologies to David Bowie. I never liked TVC 15 until I saw him perform it in concert. Saw a reddit post about how Frank Zappa was so pissed off at him for stealing his guitarist that claimed the only thing he said to Bowie was “Fuck you Captain Tom.”
All I can say is that I asked my friend Richie Stotts about it without mentioning the guitarist’s name. He said “Adrien Belew?” Evidently reddit thinks that is a bullshit website. Reddit is the new Onion except they are not as honest about all the lying bringing in their revenue. Some people did stuff and actually know things. Now get off my lawn.

Revisiting the ODBC code I wrote for Excel. https://xllodbc.codeplex.com. And looking at what I checked in today. Jeez, forgot to delete the old stuff I’ve been moving over. Not only does code not write itself, it also does not delete your improved code. At least I had some fun tonight going to the local library for chess night with my friend and her son. Met a very cool guy that makes that happen. From Jamaica. He has an easy style with the kids. Let them make mistakes, and feed them with different things until they see a spark.

I know, ODBC is an ancient API. I needed to get a parameterized stored procedure call into Excel for a project.  There are all sorts of amazing new technologies happening with big data and Power Pivot, etc…, but all I needed was to call a stored procedure with parameters you can type into Excel. Please tell me if I’m missing something, it is getting increasingly difficult to keep up with the latest technology.

This is my third iteration through the code. When you work for big companies you don’t have this luxury. ODBC defines SQLCHAR to be unsigned. This was before the days of Unicode so I’m guessing they were trying to accommodate “funny” characters.  The latest C++2011 standard lets you decorate string literals for this, but there is no provision for unsigned chars. You have to use reinterpret_cast for that. Seems a bit drastic.

The other pisser is that it is written in C and you have to worry about managing the memory to strings. If they could just stick to (pointer, length, length_ptr), with the same types, that would be great.

The other trick is how to hook that up with std::string/std::basic_string<T>. There is a provision in the API to find out the exact string length, but why bother? Pass it a string with enough reserve and resize it. Make length_ptr a class and use a macro to call that and have the destructor do the resizing. Like this: https://xllodbc.codeplex.com/SourceControl/latest#xllodbc.h

My fourth iteration will be better.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s