execQueryMultiParams method

Uint8List? execQueryMultiParams(
  1. int connectionId,
  2. String sql,
  3. Uint8List? paramsBuffer, {
  4. int? maxBufferBytes,
  5. int? initialBufferBytes,
  6. int fetchSize = 0,
})
inherited

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,
  int? initialBufferBytes,
  int fetchSize = 0,
}) {
  if (!_bindings.supportsExecQueryMultiParams) {
    throw StateError(
      'odbc_exec_query_multi_params requires odbc_engine >= 3.2.0',
    );
  }
  final useFetch =
      fetchSize > 0 && _bindings.supportsExecQueryMultiParamsFetch;
  return _withSql(
    sql,
    (sqlPtr) {
      final hasParams = paramsBuffer != null && paramsBuffer.isNotEmpty;
      if (hasParams) {
        return _withParamsBuffer(
          paramsBuffer,
          (paramsPtr) => callWithBuffer(
            (buf, bufLen, outWritten) => useFetch
                ? _bindings.odbc_exec_query_multi_params_fetch(
                    connectionId,
                    sqlPtr,
                    paramsPtr,
                    paramsBuffer.length,
                    fetchSize,
                    buf,
                    bufLen,
                    outWritten,
                  )
                : _bindings.odbc_exec_query_multi_params(
                    connectionId,
                    sqlPtr,
                    paramsPtr,
                    paramsBuffer.length,
                    buf,
                    bufLen,
                    outWritten,
                  ),
            maxSize: maxBufferBytes,
            initialSize: initialBufferBytes,
            preferTransient: preferTransientFfiBufferForParams(paramsBuffer),
          ),
        );
      }
      return callWithBuffer(
        (buf, bufLen, outWritten) => useFetch
            ? _bindings.odbc_exec_query_multi_params_fetch(
                connectionId,
                sqlPtr,
                null,
                0,
                fetchSize,
                buf,
                bufLen,
                outWritten,
              )
            : _bindings.odbc_exec_query_multi_params(
                connectionId,
                sqlPtr,
                null,
                0,
                buf,
                bufLen,
                outWritten,
              ),
        maxSize: maxBufferBytes,
        initialSize: initialBufferBytes,
      );
    },
  );
}