public static void TriggerWithBody_InitiallyDisabled()
        {
            var body = new PlSqlBlockStatement();
            body.Statements.Add(new OpenStatement("c1"));
            body.Statements.Add(new CursorForLoopStatement("i", "c1"));
            body.Statements.Add(new ReturnStatement());

            var statement = new CreateTriggerStatement(ObjectName.Parse("APP.trig1"), new ObjectName("tab1"), body,
                TriggerEventTime.Before, TriggerEventType.Insert | TriggerEventType.Update) {
                    Status = TriggerStatus.Disabled,
                    ReplaceIfExists = true
                };

            var expected = new StringBuilder();
            expected.AppendLine("CREATE OR REPLACE TRIGGER APP.trig1 BEFORE INSERT OR UPDATE ON tab1 DISABLE");
            expected.AppendLine("  BEGIN");
            expected.AppendLine("    OPEN c1");
            expected.AppendLine("    FOR i IN c1");
            expected.AppendLine("    LOOP");
            expected.AppendLine("    END LOOP");
            expected.AppendLine("    RETURN");
            expected.Append("  END");

            Assert.AreEqual(expected.ToString(), statement.ToString());
        }
Ejemplo n.º 2
0
        public static void TriggerWithBody_InitiallyDisabled()
        {
            var body = new PlSqlBlockStatement();

            body.Statements.Add(new OpenStatement("c1"));
            body.Statements.Add(new CursorForLoopStatement("i", "c1"));
            body.Statements.Add(new ReturnStatement());

            var statement = new CreateTriggerStatement(ObjectName.Parse("APP.trig1"), new ObjectName("tab1"), body,
                                                       TriggerEventTime.Before, TriggerEventType.Insert | TriggerEventType.Update)
            {
                Status          = TriggerStatus.Disabled,
                ReplaceIfExists = true
            };

            var expected = new StringBuilder();

            expected.AppendLine("CREATE OR REPLACE TRIGGER APP.trig1 BEFORE INSERT OR UPDATE ON tab1 DISABLE");
            expected.AppendLine("  BEGIN");
            expected.AppendLine("    OPEN c1");
            expected.AppendLine("    FOR i IN c1");
            expected.AppendLine("    LOOP");
            expected.AppendLine("    END LOOP");
            expected.AppendLine("    RETURN");
            expected.Append("  END");

            Assert.AreEqual(expected.ToString(), statement.ToString());
        }
Ejemplo n.º 3
0
        protected virtual SqlStatement VisitCreateTrigger(CreateTriggerStatement statement)
        {
            var body = statement.Body;

            if (body != null)
            {
                // TODO: Maybe the body should be generic to support this model
                body = (PlSqlBlockStatement)VisitStatement(body);
            }

            return(new CreateTriggerStatement(statement.TriggerName, statement.TableName, body, statement.EventTime, statement.EventType));
        }
Ejemplo n.º 4
0
 protected override SqlStatement VisitCreateTrigger(CreateTriggerStatement statement)
 {
     return(base.VisitCreateTrigger(statement));
 }
Ejemplo n.º 5
0
        protected virtual SqlStatement VisitCreateTrigger(CreateTriggerStatement statement)
        {
            var body = statement.Body;
            if (body != null)
                // TODO: Maybe the body should be generic to support this model
                body = (PlSqlBlockStatement)VisitStatement(body);

            return new CreateTriggerStatement(statement.TriggerName, statement.TableName, body, statement.EventTime, statement.EventType);
        }
Ejemplo n.º 6
0
        public void CreateTrigger()
        {
            var body = new PlSqlBlockStatement();
            body.Statements.Add(new OpenStatement("c1"));
            body.Statements.Add(new CursorForLoopStatement("i", "c1"));
            body.Statements.Add(new ReturnStatement());

            var statement = new CreateTriggerStatement(ObjectName.Parse("APP.trig1"), new ObjectName("tab1"), body,
                TriggerEventTime.Before, TriggerEventType.Insert | TriggerEventType.Update);

            SerializeAndAssert(statement, (serialized, deserialized) => {
                Assert.IsNotNull(deserialized);
                Assert.IsNotNull(deserialized.TriggerName);
                Assert.IsNotNull(deserialized.TableName);
                Assert.IsNotNull(deserialized.Body);
                Assert.AreEqual("APP.trig1", deserialized.TriggerName.FullName);
                Assert.AreEqual("tab1", deserialized.TableName.FullName);
                Assert.AreEqual(TriggerEventTime.Before, deserialized.EventTime);
            });
        }
Ejemplo n.º 7
0
 protected override SqlStatement VisitCreateTrigger(CreateTriggerStatement statement)
 {
     return base.VisitCreateTrigger(statement);
 }