How can I portably implement row-wise binding of arbitrary resultsets in ODBC while avoiding alignment issues?

Row-wise binding is a pain in the backside. However, I thought the indicators (assuming you mean StrLen_or_IndPtr argument) can be specified in a separate array of SQLINTEGER/SQLLEN (depending on how new your ODBC is). Look for something like SQL_DESC_INDICATOR_PTR and there is another one for the length.

You can set these separately from the data by setting fields in the descriptor. If you do this you will avoid alignment issues and keep your row data separate from the indicator/length.

Row-wise binding is a pain in the backside. However, I thought the indicators (assuming you mean StrLen_or_IndPtr argument) can be specified in a separate array of SQLINTEGER/SQLLEN (depending on how new your ODBC is). Look for something like SQL_DESC_INDICATOR_PTR and there is another one for the length.

You can set these separately from the data by setting fields in the descriptor. If you do this you will avoid alignment issues and keep your row data separate from the indicator/length. Update: msdn.microsoft.com/en-us/library/ms71173...).aspx Update2: Just ensure the integer values (like you indicator) are correctly aligned on a 4 byte boundary or whatever Sparc requires.

If you're talking about the sentence "Indicators and length values can be stored in separate buffers by setting the SQL_DESC_INDICATOR_PTR and SQL_DESC_OCTET_LENGTH_PTR descriptor fields to different values; if this is done, the structure contains a third element. ", I think that just means that they can be in seperate fields of the 'struct', but they still need to be in the same buffer, so that won't solve the problem – Bwmat Aug 12 at 14:30 I think you are missing the point. You create a structure to contain the columns and indicators.

You then decide on your rowset size and create and array of N of your structure. You set row bind type to the sizeof your structure. When you call SQLBindCol you pass the address of the element in the first row of your structure array.

When the driver writes to the 2nd row it adds row bind type (sizeof your struct) to the value pass to SQLBindCol for each column. As such the structure can have "holes" in it and the alignment is down to you. You need to use the right types in your structure.

– bohica Aug 12 at 16:36 The thing is, this has to work for arbitrary resultsets, there is no struct. If you read the question again, I'm just using a char buffer. – Bwmat Aug 12 at 21:59 Just to clarify, I understand row-wise binding was designed to be used with structs, when you knew at compile-time the structure of the resultset.

But in my case, I need to be able to do it with arbitrary queries – Bwmat Aug 12 at 22:03 So in that case you need to ensure your indicators are aligned on a 4 bytes boundary (or whatever Sparc requires). It does not matter if you leave holes in the buffer between fields but the integer values need to be aligned. – bohica Aug 127 at 9:35.

The way I ended up dealing with it was to actually put the length indicators and the wchars in seperate, correctly typed, buffers. They don't actually have to live in the same buffer since all that ODBC does is add the 'struct size' to each address each time it wants to go the the next set. I figured out the alignment needed for WCHAR and SQLLEN by allocating two small arrays on the stack and subtracting pointers between adjacent cells.

Then I took the LCM of both of the alignments, and added padding to the buffers so each set would occupy a multiple of that space. The I fed ODBC this as a phony 'struct size'.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions