DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Public Member Functions | Protected Member Functions | Package Functions | Properties | Private Member Functions | Static Private Attributes | List of all members
Deveel.Data.Sql.Statements.SqlStatement Class Reference

Represents the foundation class of SQL statements to be executed. More...

Inheritance diagram for Deveel.Data.Sql.Statements.SqlStatement:
Deveel.Data.Sql.Statements.IStatement Deveel.Data.Serialization.ISerializable Deveel.Data.Sql.IExecutable Deveel.Data.Sql.Statements.AlterTableStatement Deveel.Data.Sql.Statements.AlterUserStatement Deveel.Data.Sql.Statements.CloseStatement Deveel.Data.Sql.Statements.CreateSchemaStatement Deveel.Data.Sql.Statements.CreateSequenceStatement Deveel.Data.Sql.Statements.CreateTableStatement Deveel.Data.Sql.Statements.CreateTableStatement.Prepared Deveel.Data.Sql.Statements.CreateUserStatement Deveel.Data.Sql.Statements.CreateViewStatement Deveel.Data.Sql.Statements.CreateViewStatement.Prepared Deveel.Data.Sql.Statements.DeclareCursorStatement Deveel.Data.Sql.Statements.DeclareVariableStatement Deveel.Data.Sql.Statements.DropSchemaStatement Deveel.Data.Sql.Statements.DropTableStatement Deveel.Data.Sql.Statements.DropTableStatement.Prepared Deveel.Data.Sql.Statements.DropViewStatement Deveel.Data.Sql.Statements.DropViewStatement.Prepared Deveel.Data.Sql.Statements.FetchStatement Deveel.Data.Sql.Statements.GrantPrivilegesStatement Deveel.Data.Sql.Statements.GrantRoleStatement Deveel.Data.Sql.Statements.InsertSelectStatement Deveel.Data.Sql.Statements.InsertSelectStatement.Prepared Deveel.Data.Sql.Statements.InsertStatement Deveel.Data.Sql.Statements.InsertStatement.Prepared Deveel.Data.Sql.Statements.LoopControlStatement Deveel.Data.Sql.Statements.OpenStatement Deveel.Data.Sql.Statements.RaiseStatement Deveel.Data.Sql.Statements.SelectIntoStatement Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared Deveel.Data.Sql.Statements.SelectStatement Deveel.Data.Sql.Statements.SelectStatement.Prepared Deveel.Data.Sql.Statements.SetUserStatusStatement Deveel.Data.Sql.Statements.UpdateFromCursorStatement Deveel.Data.Sql.Statements.UpdateFromCursorStatement.Prepared Deveel.Data.Sql.Statements.UpdateQueryStatement Deveel.Data.Sql.Statements.UpdateQueryStatement.Prepared Deveel.Data.Sql.Statements.UpdateStatement Deveel.Data.Sql.Statements.UpdateStatement.Prepared

Public Member Functions

ITable Execute (IRequest context)
 Prepares and evaluates this statement into a tabular result. More...
 

Static Public Member Functions

static IEnumerable< SqlStatementParse (string sqlSource)
 Parses a given string into one of more statements. More...
 
static IEnumerable< SqlStatementParse (IContext context, string sqlSource)
 Parses a given string into one of more statements. More...
 
static IEnumerable< SqlStatementParse (IContext context, SqlQuery query)
 

Protected Member Functions

 SqlStatement ()
 
 SqlStatement (ObjectData data)
 
virtual void ExecuteStatement (ExecutionContext context)
 
virtual void GetData (SerializeData data)
 

Package Functions

void SetSource (SqlQuery query)
 

Properties

SqlQuery SourceQuery [get, set]
 Gets the SqlQuery that is the origin of this statement. More...
 
bool IsFromQuery [get, private set]
 Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was manually created. More...
 
- Properties inherited from Deveel.Data.Sql.Statements.IStatement
SqlQuery SourceQuery [get]
 

Private Member Functions

void IExecutable. Execute (ExecutionContext context)
 
void ISerializable. GetData (SerializeData data)
 
ITable PrepareAndExecute (IExpressionPreparer preparer, IRequest context)
 

Static Private Attributes

static readonly ISqlCompiler DefaultCompiler = new SqlDefaultCompiler()
 

Detailed Description

Represents the foundation class of SQL statements to be executed.

Definition at line 32 of file SqlStatement.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Statements.SqlStatement.SqlStatement ( )
inlineprotected

Definition at line 33 of file SqlStatement.cs.

33  {
34 
35  }
Deveel.Data.Sql.Statements.SqlStatement.SqlStatement ( ObjectData  data)
inlineprotected

Definition at line 37 of file SqlStatement.cs.

37  {
38  SourceQuery = data.GetValue<SqlQuery>("SourceQuery");
39  IsFromQuery = data.GetBoolean("IsFromQuery");
40  }
bool IsFromQuery
Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was...
Definition: SqlStatement.cs:60
SqlQuery SourceQuery
Gets the SqlQuery that is the origin of this statement.
Definition: SqlStatement.cs:49

Member Function Documentation

void IExecutable. Deveel.Data.Sql.Statements.SqlStatement.Execute ( ExecutionContext  context)
inlineprivate

Implements Deveel.Data.Sql.IExecutable.

Definition at line 62 of file SqlStatement.cs.

62  {
63  ExecuteStatement(context);
64  }
virtual void ExecuteStatement(ExecutionContext context)
Definition: SqlStatement.cs:66
ITable Deveel.Data.Sql.Statements.SqlStatement.Execute ( IRequest  context)
inline

Prepares and evaluates this statement into a tabular result.

Parameters
contextThe context used to prepare and evaluate the statement.
Returns
Returns a ITable object that contains the values resulting from the evaluation of the statement.
Exceptions
StatementPrepareExceptionThrown if an error occurred while preparing the statement.

Definition at line 97 of file SqlStatement.cs.

97  {
98  return PrepareAndExecute(null, context);
99  }
ITable PrepareAndExecute(IExpressionPreparer preparer, IRequest context)
virtual void Deveel.Data.Sql.Statements.SqlStatement.ExecuteStatement ( ExecutionContext  context)
inlineprotectedvirtual
void ISerializable. Deveel.Data.Sql.Statements.SqlStatement.GetData ( SerializeData  data)
inlineprivate

Implements Deveel.Data.Serialization.ISerializable.

Definition at line 75 of file SqlStatement.cs.

75  {
76  data.SetValue("SourceQuery", SourceQuery);
77  data.SetValue("IsFromQuery", IsFromQuery);
78 
79  GetData(data);
80  }
void SetValue(string key, Type type, object value)
void ISerializable. GetData(SerializeData data)
Definition: SqlStatement.cs:75
bool IsFromQuery
Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was...
Definition: SqlStatement.cs:60
SqlQuery SourceQuery
Gets the SqlQuery that is the origin of this statement.
Definition: SqlStatement.cs:49
virtual void Deveel.Data.Sql.Statements.SqlStatement.GetData ( SerializeData  data)
inlineprotectedvirtual
static IEnumerable<SqlStatement> Deveel.Data.Sql.Statements.SqlStatement.Parse ( string  sqlSource)
inlinestatic

Parses a given string into one of more statements.

Parameters
sqlSourceThe input string to be parsed.
Returns
Returns a list of SqlStatement objects resulting from the parsing of the input string.
Exceptions
SqlParseExceptionThrown if the input string is of an invalid format and cannot form into a valid statement.

Definition at line 133 of file SqlStatement.cs.

133  {
134  return Parse(null, sqlSource);
135  }
static IEnumerable< SqlStatement > Parse(string sqlSource)
Parses a given string into one of more statements.
static IEnumerable<SqlStatement> Deveel.Data.Sql.Statements.SqlStatement.Parse ( IContext  context,
string  sqlSource 
)
inlinestatic

Parses a given string into one of more statements.

Parameters
context
sqlSourceThe input string to be parsed.
Returns
Returns a list of SqlStatement objects resulting from the parsing of the input string.
Exceptions
SqlParseExceptionThrown if the input string is of an invalid format and cannot form into a valid statement.

Definition at line 150 of file SqlStatement.cs.

150  {
151  return Parse(context, new SqlQuery(sqlSource));
152  }
static IEnumerable< SqlStatement > Parse(string sqlSource)
Parses a given string into one of more statements.
static IEnumerable<SqlStatement> Deveel.Data.Sql.Statements.SqlStatement.Parse ( IContext  context,
SqlQuery  query 
)
inlinestatic

Definition at line 158 of file SqlStatement.cs.

158  {
159  if (query == null)
160  throw new ArgumentNullException("query");
161 
162  var compiler = DefaultCompiler;
163 
164  if (context != null) {
165  compiler = context.ResolveService<ISqlCompiler>();
166  }
167 
168  try {
169  var compileContext = new SqlCompileContext(context, query.Text);
170  var result = compiler.Compile(compileContext);
171  if (result.HasErrors)
172  throw new SqlParseException();
173 
174  var statements = result.Statements.Cast<SqlStatement>();
175 
176  foreach (var statement in statements) {
177  if (statement != null)
178  statement.SetSource(query);
179  }
180 
181  return statements;
182  } catch (SqlParseException) {
183  throw;
184  } catch (Exception ex) {
185  throw new SqlParseException("The input string cannot be parsed into SQL Statements", ex);
186  }
187  }
static readonly ISqlCompiler DefaultCompiler
An error that occurs when compiling a input string into a SQL object.
ITable Deveel.Data.Sql.Statements.SqlStatement.PrepareAndExecute ( IExpressionPreparer  preparer,
IRequest  context 
)
inlineprivate

Definition at line 101 of file SqlStatement.cs.

101  {
102  IExecutable prepared;
103 
104  try {
105  prepared = this.Prepare(preparer, context);
106  } catch (Exception ex) {
107  throw new InvalidOperationException("Unable to prepare the statement for execution.", ex);
108  }
109 
110  if (prepared == null)
111  throw new InvalidOperationException();
112 
113  var exeContext = new ExecutionContext(context);
114  prepared.Execute(exeContext);
115  if (!exeContext.HasResult)
116  return FunctionTable.ResultTable(context, 0);
117 
118  return exeContext.Result;
119  }
static ITable ResultTable(IRequest context, SqlExpression expression)
void Deveel.Data.Sql.Statements.SqlStatement.SetSource ( SqlQuery  query)
inlinepackage

Definition at line 70 of file SqlStatement.cs.

70  {
71  SourceQuery = query;
72  IsFromQuery = true;
73  }
bool IsFromQuery
Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was...
Definition: SqlStatement.cs:60
SqlQuery SourceQuery
Gets the SqlQuery that is the origin of this statement.
Definition: SqlStatement.cs:49

Member Data Documentation

readonly ISqlCompiler Deveel.Data.Sql.Statements.SqlStatement.DefaultCompiler = new SqlDefaultCompiler()
staticprivate

Definition at line 154 of file SqlStatement.cs.

Property Documentation

bool Deveel.Data.Sql.Statements.SqlStatement.IsFromQuery
getprivate set

Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was manually created.

When this value is true the value returned by SourceQuery is not null.

See also
SourceQuery

Definition at line 60 of file SqlStatement.cs.

SqlQuery Deveel.Data.Sql.Statements.SqlStatement.SourceQuery
getset

Gets the SqlQuery that is the origin of this statement.

A single SQL query can form multiple SqlStatement objects.

See also
SqlQuery

Definition at line 49 of file SqlStatement.cs.


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