DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Protected Member Functions | Package Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared Class Reference
Inheritance diagram for Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared:
Deveel.Data.Sql.Statements.SqlStatement Deveel.Data.Sql.Statements.IStatement Deveel.Data.Serialization.ISerializable Deveel.Data.Sql.IExecutable

Protected Member Functions

override void GetData (SerializeData data)
 
override void ExecuteStatement (ExecutionContext context)
 
- Protected Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
 SqlStatement ()
 
 SqlStatement (ObjectData data)
 

Package Functions

 Prepared (IQueryPlanNode queryPlan, ObjectName table)
 
 Prepared (IQueryPlanNode queryPlan, string varName)
 
- Package Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
void SetSource (SqlQuery query)
 

Properties

bool IsForTable [get, private set]
 
IQueryPlanNode QueryPlan [get, private set]
 
ObjectName Table [get, private set]
 
string VariableName [get, private set]
 
- Properties inherited from Deveel.Data.Sql.Statements.SqlStatement
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

 Prepared (IQueryPlanNode queryPlan)
 
 Prepared (ObjectData data)
 
void SelectIntoTable (IMutableTable table, ITable result)
 
bool AreCompatible (TableInfo a, TableInfo b)
 

Additional Inherited Members

- Public Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
ITable Execute (IRequest context)
 Prepares and evaluates this statement into a tabular result. More...
 
- Static Public Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
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)
 

Detailed Description

Definition at line 68 of file SelectIntoStatement.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.Prepared ( IQueryPlanNode  queryPlan,
ObjectName  table 
)
inlinepackage

Definition at line 69 of file SelectIntoStatement.cs.

70  : this(queryPlan) {
71  IsForTable = true;
72  Table = table;
73  }
Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.Prepared ( IQueryPlanNode  queryPlan,
string  varName 
)
inlinepackage

Definition at line 75 of file SelectIntoStatement.cs.

Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.Prepared ( IQueryPlanNode  queryPlan)
inlineprivate

Definition at line 81 of file SelectIntoStatement.cs.

81  {
82  QueryPlan = queryPlan;
83  }
Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.Prepared ( ObjectData  data)
inlineprivate

Definition at line 85 of file SelectIntoStatement.cs.

85  {
86  IsForTable = data.GetBoolean("IsForTable");
87  QueryPlan = data.GetValue<IQueryPlanNode>("QueryPlan");
88  Table = data.GetValue<ObjectName>("Table");
89  VariableName = data.GetString("VariableName");
90  }
A node element of a query plan tree. /summary>

Member Function Documentation

bool Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.AreCompatible ( TableInfo  a,
TableInfo  b 
)
inlineprivate

Definition at line 140 of file SelectIntoStatement.cs.

140  {
141  if (a.ColumnCount != b.ColumnCount)
142  return false;
143 
144  for (int i = 0; i < a.ColumnCount; i++) {
145  var aCol = a[i];
146  var bCol = b[i];
147  if (!aCol.ColumnType.IsComparable(bCol.ColumnType))
148  return false;
149  }
150 
151  return false;
152  }
int ColumnCount
Gets a count of the columns defined by this object.
Definition: TableInfo.cs:159
override void Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.ExecuteStatement ( ExecutionContext  context)
inlineprotectedvirtual

Reimplemented from Deveel.Data.Sql.Statements.SqlStatement.

Definition at line 107 of file SelectIntoStatement.cs.

107  {
108  var result = QueryPlan.Evaluate(context.Request);
109 
110  if (IsForTable) {
111  var table = context.Request.Query.GetMutableTable(Table);
112  if (table == null)
113  throw new StatementPrepareException(String.Format("Referenced table of the INTO statement '{0}' was not found or is not mutable.", Table));
114 
115  SelectIntoTable(table, result);
116  }
117 
118  // TODO: get the variable from ref and check if the result is compatible and set it
119 
120  throw new NotImplementedException();
121  }
void SelectIntoTable(IMutableTable table, ITable result)
A long string in the system.
ITable Evaluate(IRequest context)
override void Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.GetData ( SerializeData  data)
inlineprotectedvirtual

Reimplemented from Deveel.Data.Sql.Statements.SqlStatement.

Definition at line 100 of file SelectIntoStatement.cs.

100  {
101  data.SetValue("IsForTable", IsForTable);
102  data.SetValue("QueryPlan", QueryPlan);
103  data.SetValue("Table", Table);
104  data.SetValue("VariableName", VariableName);
105  }
void SetValue(string key, Type type, object value)
void Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.SelectIntoTable ( IMutableTable  table,
ITable  result 
)
inlineprivate

Definition at line 123 of file SelectIntoStatement.cs.

123  {
124  if (!AreCompatible(table.TableInfo, result.TableInfo))
125  throw new InvalidOperationException();
126 
127 
128  for (int i = 0; i < result.RowCount; i++) {
129  var newRow = table.NewRow();
130 
131  for (int j = 0; j < result.ColumnCount(); j++) {
132  var value = result.GetValue(i, j);
133  newRow.SetValue(j, value);
134  }
135 
136  table.AddRow(newRow);
137  }
138  }
DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
RowId AddRow(Row row)
Persists a new row to the table.
TableInfo TableInfo
Gets the metadata information of the table, used to resolve the column sources.
Definition: ITable.cs:47
int RowCount
Gets the total number of rows in the table.
Definition: ITable.cs:52

Property Documentation

bool Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.IsForTable
getprivate set

Definition at line 92 of file SelectIntoStatement.cs.

IQueryPlanNode Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.QueryPlan
getprivate set

Definition at line 94 of file SelectIntoStatement.cs.

ObjectName Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.Table
getprivate set

Definition at line 96 of file SelectIntoStatement.cs.

string Deveel.Data.Sql.Statements.SelectIntoStatement.Prepared.VariableName
getprivate set

Definition at line 98 of file SelectIntoStatement.cs.


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