Example #1
0
        public void SetLocalDeclarations(object[] declarations)
        {
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            for (int i = 0; i < declarations.Length; i++)
            {
                if (((declarations[i] is ColumnSchema) || (declarations[i] is StatementQuery)) || (declarations[i] is Condition))
                {
                    num++;
                }
                else if (declarations[i] is Table)
                {
                    num3++;
                }
                else
                {
                    num2++;
                }
            }
            this.Variables = new ColumnSchema[num];
            this.Handlers  = new StatementHandler[num2];
            if (num3 > 0)
            {
                this.Tables = new Table[num3];
            }
            num  = 0;
            num2 = 0;
            num3 = 0;
            for (int j = 0; j < declarations.Length; j++)
            {
                if (declarations[j] is ColumnSchema)
                {
                    this.Variables[num++] = (ColumnSchema)declarations[j];
                }
                else if (declarations[j] is StatementQuery)
                {
                    StatementQuery queryStatement = (StatementQuery)declarations[j];
                    Cursor         o = new Cursor(queryStatement);
                    this.Variables[num++] = new ColumnSchema(queryStatement.CursorName, SqlType.SqlAllTypes, false, false, new ExpressionValue(o, SqlType.SqlAllTypes));
                }
                else if (declarations[j] is Condition)
                {
                    Condition o = (Condition)declarations[j];
                    this.Variables[num++] = new ColumnSchema(o.Name, SqlType.SqlAllTypes, false, false, new ExpressionValue(o, SqlType.SqlAllTypes));
                }
                else if (declarations[j] is Table)
                {
                    Table table = (Table)declarations[j];
                    this.Tables[num3++] = table;
                }
                else
                {
                    StatementHandler handler = (StatementHandler)declarations[j];
                    handler.SetParent(this);
                    this.Handlers[num2++] = handler;
                    if (handler.HandlerType == 7)
                    {
                        this.HasUndoHandler = true;
                    }
                }
            }
            this.SetVariables();
            this.SetHandlers();
            this.SetTables();
        }
Example #2
0
        private Result HandleCondition(Session session, Result result)
        {
            string subString;
            int    errorCode;
            Result r = result;

            if (result.IsError())
            {
                subString = result.GetSubString();
                errorCode = result.GetErrorCode();
            }
            else
            {
                if (session.GetLastWarning() == null)
                {
                    return(result);
                }
                CoreException lastWarning = session.GetLastWarning();
                subString = lastWarning.GetSqlState();
                errorCode = lastWarning.GetErrorCode();
            }
            if ((subString != null) || (errorCode != 0))
            {
                for (int i = 0; i < this.Handlers.Length; i++)
                {
                    StatementHandler handler = this.Handlers[i];
                    session.ClearWarnings();
                    if (handler.HandlesCondition(subString, errorCode))
                    {
                        Result result3;
                        session.ResetSchema();
                        switch (handler.HandlerType)
                        {
                        case 5:
                            result = Result.UpdateZeroResult;
                            break;

                        case 6:
                            result = Result.NewPsmResult(0x59, null, null);
                            break;

                        case 7:
                            session.RollbackToSavepoint();
                            result = Result.NewPsmResult(0x59, this.label.Name, null);
                            break;
                        }
                        session.sessionContext.PushHandlerContext(r);
                        try
                        {
                            result3 = handler.Execute(session);
                        }
                        finally
                        {
                            session.sessionContext.PopHandlerContext();
                        }
                        if (result3.IsError())
                        {
                            result = result3;
                            break;
                        }
                        return(result);
                    }
                }
                if (base.Parent != null)
                {
                    return(base.Parent.HandleCondition(session, result));
                }
            }
            return(result);
        }