protected async Task ProcessStoredProcedureExecuteResponse(SqlResponse response, AsyncWrappingCommonArgs async) { try { if (response.Count > 0) { OutputParameters.Enqueue(await ReadRow(async).ConfigureAwait(false)); } } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default) { EnsureNotDeallocated(); await descriptorFiller.FillAsync(_parameters, 0, cancellationToken).ConfigureAwait(false); ClearStatusVector(); NativeHelpers.CallIfExists(() => { _db.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout); _db.ProcessStatusVector(_statusVector); }); ClearStatusVector(); var inSqlda = IntPtr.Zero; var outSqlda = IntPtr.Zero; if (_parameters != null) { inSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); } if (StatementType == DbStatementType.StoredProcedure) { Fields.ResetValues(); outSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } var trHandle = _transaction.HandlePtr; _db.FbClient.isc_dsql_execute2( _statusVector, ref trHandle, ref _handle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, outSqlda, true); var values = new DbValue[descriptor.Count]; for (var i = 0; i < values.Length; i++) { var d = descriptor[i]; var value = await d.DbValue.GetValueAsync(cancellationToken).ConfigureAwait(false); values[i] = new DbValue(this, d, value); } OutputParameters.Enqueue(values); } XsqldaMarshaler.CleanUpNativeData(ref inSqlda); XsqldaMarshaler.CleanUpNativeData(ref outSqlda); _db.ProcessStatusVector(_statusVector); if (DoRecordsAffected) { RecordsAffected = await GetRecordsAffectedAsync(cancellationToken).ConfigureAwait(false); } else { RecordsAffected = -1; } State = StatementState.Executed; }
public override void Execute() { EnsureNotDeallocated(); ClearStatusVector(); var inSqlda = IntPtr.Zero; var outSqlda = IntPtr.Zero; if (_parameters != null) { inSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); } if (StatementType == DbStatementType.StoredProcedure) { Fields.ResetValues(); outSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } var trHandle = _transaction.HandlePtr; _db.FbClient.isc_dsql_execute2( _statusVector, ref trHandle, ref _handle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, outSqlda, true); var values = new DbValue[descriptor.Count]; for (var i = 0; i < values.Length; i++) { var d = descriptor[i]; var value = d.DbValue.GetValue(); values[i] = new DbValue(this, d, value); } OutputParameters.Enqueue(values); } XsqldaMarshaler.CleanUpNativeData(ref inSqlda); XsqldaMarshaler.CleanUpNativeData(ref outSqlda); _db.ProcessStatusVector(_statusVector); if (DoRecordsAffected) { RecordsAffected = GetRecordsAffected(); } else { RecordsAffected = -1; } State = StatementState.Executed; }