execQueryParams method

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

Executes a SQL query with binary parameters.

The connectionId must be a valid active connection. The sql should be a parameterized SQL statement. The params should be a binary buffer containing serialized parameters. When maxBufferBytes is set, caps the result buffer size; otherwise uses the package default.

Returns binary result data on success, null on failure.

Implementation

Uint8List? execQueryParams(
  int connectionId,
  String sql,
  Uint8List? params, {
  int? maxBufferBytes,
}) {
  final paramsOrEmpty =
      (params == null || params.isEmpty) ? Uint8List(0) : params;
  return _withSql(
    sql,
    (ffi.Pointer<bindings.Utf8> sqlPtr) {
      return _withParamsBuffer(
        paramsOrEmpty,
        (ffi.Pointer<ffi.Uint8> paramsPtr) => callWithBuffer(
          (buf, bufLen, outWritten) => _bindings.odbc_exec_query_params(
            connectionId,
            sqlPtr,
            paramsPtr,
            paramsOrEmpty.length,
            buf,
            bufLen,
            outWritten,
          ),
          maxSize: maxBufferBytes,
        ),
      );
    },
  );
}