internal virtual async Task <ExecuteStatementResult> ExecuteStatementAsync(
            string txnId, string statement, ValueHolder[] parameters, CancellationToken cancellationToken)
        {
            try
            {
                var executeStatementRequest = new ExecuteStatementRequest
                {
                    TransactionId = txnId,
                    Statement     = statement,
                    Parameters    = parameters.ToList(),
                };
                var request = new SendCommandRequest
                {
                    ExecuteStatement = executeStatementRequest,
                };
                var response = await this.SendCommand(request, cancellationToken);

                return(response.ExecuteStatement);
            }
            catch (IOException e)
            {
                throw new QldbDriverException(ExceptionMessages.FailedToSerializeParameter + e.Message, e);
            }
            finally
            {
                if (parameters != null && parameters.Length != 0)
                {
                    foreach (ValueHolder valueHolder in parameters)
                    {
                        valueHolder.IonBinary.Dispose();
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Runs a SQL statement against a database.
        ///
        ///  <important>
        /// <para>
        /// If a call isn't part of a transaction because it doesn't include the <code>transactionID</code>
        /// parameter, changes that result from the call are committed automatically.
        /// </para>
        ///  </important>
        /// <para>
        /// The response size limit is 1 MB. If the call returns more than 1 MB of response data,
        /// the call is terminated.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ExecuteStatement service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the ExecuteStatement service method, as returned by RDSDataService.</returns>
        /// <exception cref="Amazon.RDSDataService.Model.BadRequestException">
        /// There is an error in the call or in a SQL statement.
        /// </exception>
        /// <exception cref="Amazon.RDSDataService.Model.ForbiddenException">
        /// There are insufficient privileges to make the call.
        /// </exception>
        /// <exception cref="Amazon.RDSDataService.Model.InternalServerErrorException">
        /// An internal error occurred.
        /// </exception>
        /// <exception cref="Amazon.RDSDataService.Model.ServiceUnavailableErrorException">
        /// The service specified by the <code>resourceArn</code> parameter is not available.
        /// </exception>
        /// <exception cref="Amazon.RDSDataService.Model.StatementTimeoutException">
        /// The execution of the SQL statement timed out.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rds-data-2018-08-01/ExecuteStatement">REST API Reference for ExecuteStatement Operation</seealso>
        public virtual Task <ExecuteStatementResponse> ExecuteStatementAsync(ExecuteStatementRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ExecuteStatementRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ExecuteStatementResponseUnmarshaller.Instance;

            return(InvokeAsync <ExecuteStatementResponse>(request, options, cancellationToken));
        }
Exemple #3
0
        internal virtual ExecuteStatementResponse ExecuteStatement(ExecuteStatementRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ExecuteStatementRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ExecuteStatementResponseUnmarshaller.Instance;

            return(Invoke <ExecuteStatementResponse>(request, options));
        }
Exemple #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the ExecuteStatement operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ExecuteStatement operation on AmazonRDSDataServiceClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndExecuteStatement
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rds-data-2018-08-01/ExecuteStatement">REST API Reference for ExecuteStatement Operation</seealso>
        public virtual IAsyncResult BeginExecuteStatement(ExecuteStatementRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ExecuteStatementRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ExecuteStatementResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
        /// <summary>
        /// Send an asynchronous execute request with parameters to QLDB.
        /// </summary>
        ///
        /// <param name="txnId">The unique ID of the transaction to execute.</param>
        /// <param name="statement">The PartiQL statement to execute.</param>
        /// <param name="parameters">The parameters to use with the PartiQL statement for execution.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>
        /// The result of the execution, which contains a <see cref="Page"/> representing the first data chunk.
        /// </returns>
        internal virtual async Task <ExecuteStatementResult> ExecuteStatementAsync(
            string txnId, string statement, List <IIonValue> parameters, CancellationToken cancellationToken)
        {
            List <ValueHolder> valueHolders = null;

            try
            {
                valueHolders = parameters.ConvertAll(ionValue =>
                {
                    MemoryStream stream = new MemoryStream();
                    using (var writer = IonBinaryWriterBuilder.Build(stream))
                    {
                        ionValue.WriteTo(writer);
                        writer.Finish();
                    }

                    var valueHolder = new ValueHolder
                    {
                        IonBinary = stream,
                    };
                    return(valueHolder);
                });

                var executeStatementRequest = new ExecuteStatementRequest
                {
                    TransactionId = txnId,
                    Statement     = statement,
                    Parameters    = valueHolders,
                };
                var request = new SendCommandRequest
                {
                    ExecuteStatement = executeStatementRequest,
                };
                var response = await this.SendCommand(request, cancellationToken);

                return(response.ExecuteStatement);
            }
            catch (IOException e)
            {
                throw new QldbDriverException(ExceptionMessages.FailedToSerializeParameter + e.Message, e);
            }
            finally
            {
                if (valueHolders != null)
                {
                    valueHolders.ForEach(valueHolder =>
                    {
                        valueHolder.IonBinary.Dispose();
                    });
                }
            }
        }
        /// <summary>
        /// Send an execute request with parameters to QLDB.
        /// </summary>
        ///
        /// <param name="txnId">The unique ID of the transaction to execute.</param>
        /// <param name="statement">The PartiQL statement to execute.</param>
        /// <param name="parameters">The parameters to use with the PartiQL statement for execution.</param>
        ///
        /// <returns>The result of the execution, which contains a <see cref="Page"/> representing the first data chunk.</returns>
        internal virtual ExecuteStatementResult ExecuteStatement(string txnId, string statement, List <IIonValue> parameters)
        {
            List <ValueHolder> valueHolders = null;

            try
            {
                valueHolders = parameters.ConvertAll(ionValue =>
                {
                    MemoryStream stream = new MemoryStream();
                    using (var writer = IonBinaryWriterBuilder.Build(stream))
                    {
                        ionValue.WriteTo(writer);
                        writer.Finish();
                    }

                    var valueHolder = new ValueHolder
                    {
                        IonBinary = stream,
                    };
                    return(valueHolder);
                });

                var executeStatementRequest = new ExecuteStatementRequest
                {
                    TransactionId = txnId,
                    Statement     = statement,
                    Parameters    = valueHolders,
                };
                var request = new SendCommandRequest
                {
                    ExecuteStatement = executeStatementRequest,
                };
                var response = this.SendCommand(request);
                return(response.ExecuteStatement);
            }
            finally
            {
                if (valueHolders != null)
                {
                    valueHolders.ForEach(valueHolder =>
                    {
                        valueHolder.IonBinary.Dispose();
                    });
                }
            }
        }
Exemple #7
0
 Task <ExecuteStatementResponse> IAmazonDynamoDB.ExecuteStatementAsync(ExecuteStatementRequest request, CancellationToken cancellationToken)
 {
     throw new NotSupportedException();
 }
Exemple #8
0
 public Task <ExecuteStatementResponse> ExecuteStatementAsync(ExecuteStatementRequest request, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }