@@ -2183,6 +2183,33 @@ SQLRETURN BindParameterArray(SQLHANDLE hStmt,
21832183 bufferLength = sizeof (SQLGUID);
21842184 break ;
21852185 }
2186+ case SQL_C_DEFAULT: {
2187+ // Handle NULL parameters - all values in this column should be NULL
2188+ LOG (" BindParameterArray: Binding SQL_C_DEFAULT (NULL) array - param_index=%d, count=%zu" , paramIndex, paramSetSize);
2189+
2190+ // Verify all values are indeed NULL
2191+ for (size_t i = 0 ; i < paramSetSize; ++i) {
2192+ if (!columnValues[i].is_none ()) {
2193+ LOG (" BindParameterArray: SQL_C_DEFAULT non-NULL value detected - param_index=%d, row=%zu" , paramIndex, i);
2194+ ThrowStdException (" SQL_C_DEFAULT (99) should only be used for NULL parameters at index " + std::to_string (paramIndex));
2195+ }
2196+ }
2197+
2198+ // For NULL parameters, we need to allocate a minimal buffer and set all indicators to SQL_NULL_DATA
2199+ // Use SQL_C_CHAR as a safe default C type for NULL values
2200+ char * nullBuffer = AllocateParamBufferArray<char >(tempBuffers, paramSetSize);
2201+ strLenOrIndArray = AllocateParamBufferArray<SQLLEN>(tempBuffers, paramSetSize);
2202+
2203+ for (size_t i = 0 ; i < paramSetSize; ++i) {
2204+ nullBuffer[i] = 0 ;
2205+ strLenOrIndArray[i] = SQL_NULL_DATA;
2206+ }
2207+
2208+ dataPtr = nullBuffer;
2209+ bufferLength = 1 ;
2210+ LOG (" BindParameterArray: SQL_C_DEFAULT bound - param_index=%d, all_null=true" , paramIndex);
2211+ break ;
2212+ }
21862213 default : {
21872214 LOG (" BindParameterArray: Unsupported C type - param_index=%d, C_type=%d" , paramIndex, info.paramCType );
21882215 ThrowStdException (" BindParameterArray: Unsupported C type: " + std::to_string (info.paramCType ));
0 commit comments