execQueryMultiParams method

Uint8List? execQueryMultiParams(
  1. int connectionId,
  2. String sql,
  3. Uint8List? paramsBuffer, {
  4. int? maxBufferBytes,
})

Executes a parameterised batch SQL that may return multiple result sets.

Same wire format as execQueryMulti. The Rust engine collects every result set (cursor or row-count) the batch produces in order — see M1 fix in v3.2.0.

paramsBuffer is the output of serializeParams(...). Pass null (or an empty buffer) for the no-params case (equivalent to execQueryMulti). When maxBufferBytes is set, caps the result buffer size.

Returns binary result data on success, null on failure. Throws StateError if the loaded native library predates v3.2.0.

Implementation

Uint8List? execQueryMultiParams(
  int connectionId,
  String sql,
  Uint8List? paramsBuffer, {
  int? maxBufferBytes,
}) {
  if (!_bindings.supportsExecQueryMultiParams) {
    throw StateError(
      'odbc_exec_query_multi_params requires odbc_engine >= 3.2.0',
    );
  }
  return _withSql(
    sql,
    (sqlPtr) => callWithBuffer(
      (buf, bufLen, outWritten) {
        final hasParams = paramsBuffer != null && paramsBuffer.isNotEmpty;
        if (hasParams) {
          final paramsLen = paramsBuffer.length;
          final paramsPtr = malloc<ffi.Uint8>(paramsLen);
          try {
            for (var i = 0; i < paramsLen; i++) {
              paramsPtr[i] = paramsBuffer[i];
            }
            return _bindings.odbc_exec_query_multi_params(
              connectionId,
              sqlPtr,
              paramsPtr,
              paramsLen,
              buf,
              bufLen,
              outWritten,
            );
          } finally {
            malloc.free(paramsPtr);
          }
        }
        return _bindings.odbc_exec_query_multi_params(
          connectionId,
          sqlPtr,
          null,
          0,
          buf,
          bufLen,
          outWritten,
        );
      },
      maxSize: maxBufferBytes,
    ),
  );
}