コード例 #1
0
ファイル: TemporaryTable.cs プロジェクト: tsvmks/plsqlparser
        /// <summary>
        /// Copies the contents of the row of the given Table onto the end of
        /// this table.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <remarks>
        /// Only copies columns that exist in both tables.
        /// </remarks>
        public void CopyFrom(Table table, int row)
        {
            NewRow();

            ObjectName[] vars = new ObjectName[table.ColumnCount];
            for (int i = 0; i < vars.Length; ++i)
            {
                vars[i] = table.GetResolvedVariable(i);
            }

            for (int i = 0; i < ColumnCount; ++i)
            {
                ObjectName v        = GetResolvedVariable(i);
                String     col_name = v.Name;
                try {
                    int tcol_index = -1;
                    for (int n = 0; n < vars.Length || tcol_index == -1; ++n)
                    {
                        if (vars[n].Name.Equals(col_name))
                        {
                            tcol_index = n;
                        }
                    }
                    SetRowCell(table.GetValue(tcol_index, row), i, row_count - 1);
                } catch (Exception e) {
                    throw new ApplicationException(e.Message, e);
                }
            }
        }
コード例 #2
0
ファイル: CompositeTable.cs プロジェクト: tsvmks/plsqlparser
 /// <inheritdoc/>
 public override ObjectName GetResolvedVariable(int column)
 {
     return(masterTable.GetResolvedVariable(column));
 }
コード例 #3
0
ファイル: QueryResult.old.cs プロジェクト: prepare/deveeldb
        /// <summary>
        /// Constructs the result set.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="result"></param>
        public QueryResult(SqlQuery query, Table result)
        {
            this.query = query;
            this.result = result;
            streamableBlobMap = new Dictionary<long, StreamableObject>();

            resultRowCount = result.RowCount;

            // HACK: Read the contents of the first row so that we can pick up
            //   any errors with reading, and also to fix the 'uniquekey' bug
            //   that causes a new transaction to be started if 'uniquekey' is
            //   a column and the value is resolved later.
            IRowEnumerator rowEnum = result.GetRowEnumerator();
            if (rowEnum.MoveNext()) {
                int rowIndex = rowEnum.RowIndex;
                for (int c = 0; c < result.ColumnCount; ++c) {
                    result.GetCell(c, rowIndex);
                }
            }

            // If simple enum, note it here
            resultIsSimpleEnum = (rowEnum is SimpleRowEnumerator);
            rowEnum = null;

            // Build 'row_index_map' if not a simple enum
            if (!resultIsSimpleEnum) {
                rowIndexMap = new List<int>(result.RowCount);

                IRowEnumerator en = result.GetRowEnumerator();
                while (en.MoveNext()) {
                    rowIndexMap.Add(en.RowIndex);
                }
            }

            // This is a safe operation provides we are shared.
            // Copy all the TableField columns from the table to our own
            // QueryResultColumn array, naming each column by what is returned from
            // the 'GetResolvedVariable' method.
            int colCount = result.ColumnCount;
            colDesc = new QueryResultColumn[colCount];
            for (int i = 0; i < colCount; ++i) {
                VariableName v = result.GetResolvedVariable(i);
                string fieldName;
                if (v.TableName == null) {
                    // This means the column is an alias
                    fieldName = String.Format("@a{0}", v.Name);
                } else {
                    // This means the column is an schema/table/column reference
                    fieldName = String.Format("@f{0}", v);
                }

                colDesc[i] = new QueryResultColumn(fieldName, result.GetColumnInfo(i));
            }

            locked = 0;
        }
コード例 #4
0
        /// <summary>
        /// Copies the contents of the row of the given Table onto the end of 
        /// this table.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <remarks>
        /// Only copies columns that exist in both tables.
        /// </remarks>
        public void CopyFrom(Table table, int row)
        {
            NewRow();

            ObjectName[] vars = new ObjectName[table.ColumnCount];
            for (int i = 0; i < vars.Length; ++i) {
                vars[i] = table.GetResolvedVariable(i);
            }

            for (int i = 0; i < ColumnCount; ++i) {
                ObjectName v = GetResolvedVariable(i);
                String col_name = v.Name;
                try {
                    int tcol_index = -1;
                    for (int n = 0; n < vars.Length || tcol_index == -1; ++n) {
                        if (vars[n].Name.Equals(col_name)) {
                            tcol_index = n;
                        }
                    }
                    SetRowCell(table.GetValue(tcol_index, row), i, row_count - 1);
                } catch (Exception e) {
                    throw new ApplicationException(e.Message, e);
                }
            }
        }
コード例 #5
0
ファイル: JoinedTable.cs プロジェクト: tsvmks/plsqlparser
        /// <inheritdoc/>
        public override ObjectName GetResolvedVariable(int column)
        {
            Table parentTable = referenceList[columnTable[column]];

            return(parentTable.GetResolvedVariable(columnFilter[column]));
        }