Exemple #1
0
        public override void Compile(Session session, ISchemaObject parentObject)
        {
            using (Scanner scanner = new Scanner(this.statement))
            {
                ParserDQL rdql = new ParserDQL(session, scanner);
                rdql.Read();
                this.ViewSubQuery    = rdql.XreadViewSubquery(this);
                base.queryExpression = this.ViewSubQuery.queryExpression;
                if (base.GetColumnCount() == 0)
                {
                    if (this.ColumnNames == null)
                    {
                        this.ColumnNames = this.ViewSubQuery.queryExpression.GetResultColumnNames();
                    }
                    if (this.ColumnNames.Length != this.ViewSubQuery.queryExpression.GetColumnCount())
                    {
                        throw Error.GetError(0x15d9, this.GetName().StatementName);
                    }
                    TableUtil.SetColumnsInSchemaTable(this, this.ColumnNames, base.queryExpression.GetColumnTypes(), base.queryExpression.GetColumnNullability());
                }
                OrderedHashSet <SubQuery> set = OrderedHashSet <SubQuery> .AddAll(OrderedHashSet <SubQuery> .Add(base.queryExpression.GetSubqueries(), this.ViewSubQuery), this.ViewSubQuery.GetExtraSubqueries());

                this.ViewSubqueries = new SubQuery[set.Size()];
                set.ToArray(this.ViewSubqueries);
                ArraySort.Sort <SubQuery>(this.ViewSubqueries, 0, this.ViewSubqueries.Length, this.ViewSubqueries[0]);
                foreach (SubQuery query in this.ViewSubqueries)
                {
                    if (query.ParentView == null)
                    {
                        query.ParentView = this;
                    }
                    query.PrepareTable(session);
                }
                this.ViewSubQuery.GetTable().view       = this;
                this.ViewSubQuery.GetTable().ColumnList = base.ColumnList;
                this._schemaObjectNames = rdql.compileContext.GetSchemaObjectNames();
                this._baseTable         = base.queryExpression.GetBaseTable();
            }
            if (this._baseTable != null)
            {
                switch (this._check)
                {
                case 0:
                case 2:
                    return;

                case 1:
                    base.queryExpression.GetCheckCondition();
                    return;
                }
                throw Error.RuntimeError(0xc9, "View");
            }
        }
Exemple #2
0
 private void Recompile(Session session, Table newTable)
 {
     using (Scanner scanner = new Scanner(this.Check.GetSql()))
     {
         ParserDQL rdql1 = new ParserDQL(session, scanner);
         rdql1.compileContext.Reset(0);
         rdql1.Read();
         rdql1.IsCheckOrTriggerCondition = true;
         Expression expression = rdql1.XreadBooleanValueExpression();
         this.Check = expression;
         QuerySpecification specification = Expression.GetCheckSelect(session, newTable, this.Check);
         this.RangeVar = specification.RangeVariables[0];
         this.RangeVar.SetForCheckConstraint();
     }
 }