DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Static Public Member Functions | List of all members
Deveel.Data.Sql.Statements.StatementExecutor Class Reference

This class is used to transform an input query to a set of statements and execute them within a given query. More...

Classes

class  QueryPreparer
 

Static Public Member Functions

static ITable[] Execute (IRequest query, SqlQuery sqlQuery)
 This method transforms the input SQL query into a set of statements, prepares and executes them against the provided query. More...
 

Detailed Description

This class is used to transform an input query to a set of statements and execute them within a given query.

Definition at line 32 of file StatementExecutor.cs.

Member Function Documentation

static ITable [] Deveel.Data.Sql.Statements.StatementExecutor.Execute ( IRequest  query,
SqlQuery  sqlQuery 
)
inlinestatic

This method transforms the input SQL query into a set of statements, prepares and executes them against the provided query.

Parameters
queryThe query used to prepare and execute the statements resolved from the compilation of the input query.
sqlQueryThe input SQL query with optional parameters, that is compiled into a set of statements to be executed.

The method first tries to resolve the compiled statements from the specialized cache (StatementCache) from the system, to reduce the compilation time.

Returns
Returns an array of ITable objects that represent the results of the execution of the input query.

Definition at line 49 of file StatementExecutor.cs.

49  {
50  if (query == null)
51  throw new ArgumentNullException("query");
52 
53  var sqlSouce = sqlQuery.Text;
54 
55  // TODO: find it from the cache...
56 
57  var statements = SqlStatement.Parse(sqlSouce);
58 
59  // TODO: set it in cache ...
60 
61  var preparer = new QueryPreparer(sqlQuery);
62 
63  bool statementSeen = false;
64 
65  var results = new List<ITable>();
66  foreach (var statement in statements) {
67  // TODO: query.RegisterQuery(statement);
68 
69  // TODO: Invoke diagnostics for the preparation...
70 
71  var prepared = statement.Prepare(preparer, query);
72 
73  ITable result;
74 
75  try {
76  var exeContext = new ExecutionContext(query);
77  prepared.Execute(exeContext);
78  if (exeContext.HasResult) {
79  result = exeContext.Result;
80  } else {
81  result = FunctionTable.ResultTable(query, 0);
82  }
83  } catch(StatementException ex) {
84  // TODO: query.RegisterError(ex);
85  throw;
86  } catch (Exception ex) {
87  var sex = new StatementException("An unhanded error occurred while executing the statement.", ex);
88  // TODO: query.RegisterError(sex);
89  throw sex;
90  } finally {
91  statementSeen = true;
92  }
93 
94  results.Add(result);
95  }
96 
97  if (!statementSeen)
98  throw new SqlParseException("The input query was not parsed in any statements that could be executed.");
99 
100  return results.ToArray();
101  }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
static ITable ResultTable(IRequest context, SqlExpression expression)
An error that occurs when compiling a input string into a SQL object.

The documentation for this class was generated from the following file: