execute method

Uint8List? execute(
  1. int stmtId, [
  2. Uint8List? params,
  3. int timeoutOverrideMs = 0,
  4. int fetchSize = 1000,
  5. int? maxBufferBytes,
])

Executes a prepared statement with optional binary parameters.

The stmtId must be a valid prepared statement identifier. The params should be a binary buffer containing serialized parameters, or null if no parameters are needed. The timeoutOverrideMs overrides statement timeout (0 = use stored). The fetchSize specifies rows per batch (default: 1000). When maxBufferBytes is set, caps the result buffer size.

Returns binary result data on success, null on failure.

Implementation

Uint8List? execute(
  int stmtId, [
  Uint8List? params,
  int timeoutOverrideMs = 0,
  int fetchSize = 1000,
  int? maxBufferBytes,
]) {
  if (params == null || params.isEmpty) {
    return callWithBuffer(
      (buf, bufLen, outWritten) => _bindings.odbc_execute(
        stmtId,
        ffi.nullptr,
        0,
        timeoutOverrideMs,
        fetchSize,
        buf,
        bufLen,
        outWritten,
      ),
      maxSize: maxBufferBytes,
    );
  }
  return _withParamsBuffer(
    params,
    (paramsPtr) => callWithBuffer(
      (buf, bufLen, outWritten) => _bindings.odbc_execute(
        stmtId,
        paramsPtr,
        params.length,
        timeoutOverrideMs,
        fetchSize,
        buf,
        bufLen,
        outWritten,
      ),
      maxSize: maxBufferBytes,
    ),
  );
}