Пример #1
0
 public NativeResult Execute(NativeSessionInfo sessionInfo, string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
 {
     try
     {
         var          channel = GetInterface();
         IAsyncResult result  = channel.BeginExecuteStatement(sessionInfo, statement, paramsValue, options, null, null);
         result.AsyncWaitHandle.WaitOne();
         return(channel.EndExecuteStatement(result));
     }
     catch (FaultException <NativeCLIFault> exception)
     {
         throw NativeCLIFaultUtility.FaultToException(exception.Detail);
     }
 }
Пример #2
0
        public NativeResult Execute(string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
        {
            IServerScript script = _process.PrepareScript(statement);

            try
            {
                if (script.Batches.Count != 1)
                {
                    throw new ArgumentException("Execution statement must contain one, and only one, batch.");
                }

                IServerBatch batch      = script.Batches[0];
                DataParams   dataParams = NativeMarshal.NativeParamsToDataParams((Server.ServerProcess)_process, paramsValue);
                NativeResult result     = new NativeResult();
                result.Params = paramsValue;

                if (batch.IsExpression())
                {
                    IServerExpressionPlan expressionPlan = batch.PrepareExpression(dataParams);
                    try
                    {
                        if (expressionPlan.DataType is Schema.TableType)
                        {
                            if (options != NativeExecutionOptions.SchemaOnly)
                            {
                                IServerCursor cursor = expressionPlan.Open(dataParams);
                                try
                                {
                                    result.Value = NativeMarshal.ServerCursorToNativeValue(_process, cursor);
                                }
                                finally
                                {
                                    expressionPlan.Close(cursor);
                                }
                            }
                            else
                            {
                                result.Value = NativeMarshal.TableVarToNativeTableValue(_process, expressionPlan.TableVar);
                            }
                        }
                        else
                        {
                            if (options != NativeExecutionOptions.SchemaOnly)
                            {
                                using (IDataValue tempValue = expressionPlan.Evaluate(dataParams))
                                {
                                    result.Value = NativeMarshal.DataValueToNativeValue(_process, tempValue);
                                }
                            }
                            else
                            {
                                result.Value = NativeMarshal.DataTypeToNativeValue(_process, expressionPlan.DataType);
                            }
                        }
                    }
                    finally
                    {
                        batch.UnprepareExpression(expressionPlan);
                    }
                }
                else
                {
                    IServerStatementPlan statementPlan = batch.PrepareStatement(dataParams);
                    try
                    {
                        if (options != NativeExecutionOptions.SchemaOnly)
                        {
                            statementPlan.Execute(dataParams);
                        }
                    }
                    finally
                    {
                        batch.UnprepareStatement(statementPlan);
                    }
                }

                if (options != NativeExecutionOptions.SchemaOnly)
                {
                    NativeMarshal.SetNativeOutputParams(_process, result.Params, dataParams);
                }
                return(result);
            }
            finally
            {
                _process.UnprepareScript(script);
            }
        }
Пример #3
0
 public NativeResult Execute(NativeSessionHandle sessionHandle, string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
 {
     try
     {
         return(GetNativeSession(sessionHandle).Execute(statement, paramsValue, options));
     }
     catch (Exception exception)
     {
         throw NativeCLIUtility.WrapException(exception);
     }
 }
Пример #4
0
 public NativeResult Execute(NativeSessionInfo sessionInfo, string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
 {
     try
     {
         NativeSession nativeSession = StartNativeSession(sessionInfo);
         try
         {
             return(nativeSession.Execute(statement, paramsValue, options));
         }
         finally
         {
             StopNativeSession(nativeSession);
         }
     }
     catch (Exception exception)
     {
         throw NativeCLIUtility.WrapException(exception);
     }
 }
Пример #5
0
 public NativeResult SessionExecuteStatement(NativeSessionHandle sessionHandle, string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
 {
     try
     {
         return(_nativeServer.Execute(sessionHandle, statement, paramsValue, options));
     }
     catch (NativeCLIException exception)
     {
         throw new FaultException <NativeCLIFault>(NativeCLIFaultUtility.ExceptionToFault(exception), exception.Message);
     }
 }
Пример #6
0
 public NativeResult Execute(string statement, NativeParam[] paramsValue, NativeExecutionOptions options)
 {
     return(_nativeCLI.Execute(_sessionHandle, statement, paramsValue, options));
 }