Ejemplo n.º 1
0
 public static void CreateProcedureTrigger(this IQuery query, ObjectName triggerName, ObjectName tableName,
                                           ObjectName procedureName, InvokeArgument[] procedureArgs,
                                           TriggerEventTime eventTime, TriggerEventType eventType)
 {
     query.ExecuteStatement(new CreateProcedureTriggerStatement(triggerName, tableName, procedureName, procedureArgs,
                                                                eventTime, eventType));
 }
Ejemplo n.º 2
0
        public PlSqlTriggerInfo(ObjectName triggerName, ObjectName tabbleName, TriggerEventTime eventTime, TriggerEventType eventType, PlSqlBlockStatement body)
            : base(triggerName, TriggerType.Procedural, tabbleName, eventTime, eventType)
        {
            if (body == null)
                throw new ArgumentNullException("body");

            Body = body;
        }
Ejemplo n.º 3
0
        public ProcedureTriggerInfo(ObjectName triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType, ObjectName procedureName, InvokeArgument[] args)
            : base(triggerName, TriggerType.External, tableName, eventTime, eventType)
        {
            if (procedureName == null)
                throw new ArgumentNullException("procedureName");

            ProcedureName = procedureName;
            Arguments = args;
        }
Ejemplo n.º 4
0
        private bool MatchesEvent(TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (eventTime != EventTime)
            {
                return(false);
            }

            return((EventType & eventType) != 0);
        }
Ejemplo n.º 5
0
        public PlSqlTriggerInfo(ObjectName triggerName, ObjectName tabbleName, TriggerEventTime eventTime, TriggerEventType eventType, PlSqlBlockStatement body)
            : base(triggerName, TriggerType.Procedural, tabbleName, eventTime, eventType)
        {
            if (body == null)
            {
                throw new ArgumentNullException("body");
            }

            Body = body;
        }
Ejemplo n.º 6
0
        public ProcedureTriggerInfo(ObjectName triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType, ObjectName procedureName, InvokeArgument[] args)
            : base(triggerName, TriggerType.External, tableName, eventTime, eventType)
        {
            if (procedureName == null)
            {
                throw new ArgumentNullException("procedureName");
            }

            ProcedureName = procedureName;
            Arguments     = args;
        }
Ejemplo n.º 7
0
        internal TableEvent(ITable table, TriggerEventTime eventTime, TriggerEventType eventType, RowId oldRowId, Row newRow)
        {
            if (table == null)
                throw new ArgumentNullException("table");

            Table = table;
            EventTime = eventTime;
            EventType = eventType;
            OldRowId = oldRowId;
            NewRow = newRow;
        }
        public CreateCallbackTriggerStatement(string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (String.IsNullOrEmpty(triggerName))
                throw new ArgumentNullException("triggerName");
            if (tableName == null)
                throw new ArgumentNullException("tableName");

            TriggerName = triggerName;
            TableName = tableName;
            EventTime = eventTime;
            EventType = eventType;
        }
Ejemplo n.º 9
0
        protected TriggerInfo(ObjectName triggerName, TriggerType triggerType, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
                throw new ArgumentNullException("triggerName");
            if (tableName == null)
                throw new ArgumentNullException("tableName");

            TriggerName = triggerName;
            TriggerType = triggerType;
            TableName = tableName;
            EventTime = eventTime;
            EventType = eventType;
        }
Ejemplo n.º 10
0
        internal TableEvent(ITable table, TriggerEventTime eventTime, TriggerEventType eventType, RowId oldRowId, Row newRow)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            Table     = table;
            EventTime = eventTime;
            EventType = eventType;
            OldRowId  = oldRowId;
            NewRow    = newRow;
        }
Ejemplo n.º 11
0
        public static void CreateProcedureTrigger(this IQuery query, ObjectName triggerName, ObjectName tableName,
                                                  ObjectName procedureName, SqlExpression[] procedureArgs,
                                                  TriggerEventTime eventTime, TriggerEventType eventType)
        {
            var args = new InvokeArgument[0];

            if (procedureArgs != null)
            {
                args = procedureArgs.Select(x => new InvokeArgument(x)).ToArray();
            }

            query.ExecuteStatement(new CreateProcedureTriggerStatement(triggerName, tableName, procedureName, args,
                                                                       eventTime, eventType));
        }
Ejemplo n.º 12
0
        internal TriggerEvent(TriggerType triggerType, ObjectName triggerName, ObjectName sourceName, TriggerEventTime eventTime, TriggerEventType eventType, RowId oldRowId, Row newRow)
        {
            if (triggerName == null)
                throw new ArgumentNullException("triggerName");
            if (sourceName == null)
                throw new ArgumentNullException("sourceName");

            TriggerType = triggerType;
            TriggerName = triggerName;
            SourceName = sourceName;
            EventTime = eventTime;
            EventType = eventType;
            OldRowId = oldRowId;
            NewRow = newRow;
        }
Ejemplo n.º 13
0
        public CreateTriggerStatement(ObjectName triggerName, ObjectName tableName, PlSqlBlockStatement body, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
                throw new ArgumentNullException("triggerName");
            if (tableName == null)
                throw new ArgumentNullException("tableName");
            if (body == null)
                throw new ArgumentNullException("body");

            TriggerName = triggerName;
            TableName = tableName;
            Body = body;
            EventTime = eventTime;
            EventType = eventType;
        }
        public CreateCallbackTriggerStatement(string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (String.IsNullOrEmpty(triggerName))
            {
                throw new ArgumentNullException("triggerName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }

            TriggerName = triggerName;
            TableName   = tableName;
            EventTime   = eventTime;
            EventType   = eventType;
        }
        public CreateProcedureTriggerStatement(ObjectName triggerName, ObjectName tableName, ObjectName procedureName, InvokeArgument[] args, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
                throw new ArgumentNullException("triggerName");
            if (tableName == null)
                throw new ArgumentNullException("tableName");
            if (procedureName == null)
                throw new ArgumentNullException("procedureName");

            TriggerName = triggerName;
            TableName = tableName;
            ProcedureName = procedureName;
            ProcedureArguments = args;
            EventTime = eventTime;
            EventType = eventType;
        }
Ejemplo n.º 16
0
        protected TriggerInfo(ObjectName triggerName, TriggerType triggerType, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
            {
                throw new ArgumentNullException("triggerName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }

            TriggerName = triggerName;
            TriggerType = triggerType;
            TableName   = tableName;
            EventTime   = eventTime;
            EventType   = eventType;
        }
Ejemplo n.º 17
0
        internal TriggerEvent(TriggerType triggerType, ObjectName triggerName, ObjectName sourceName, TriggerEventTime eventTime, TriggerEventType eventType, RowId oldRowId, Row newRow)
        {
            if (triggerName == null)
            {
                throw new ArgumentNullException("triggerName");
            }
            if (sourceName == null)
            {
                throw new ArgumentNullException("sourceName");
            }

            TriggerType = triggerType;
            TriggerName = triggerName;
            SourceName  = sourceName;
            EventTime   = eventTime;
            EventType   = eventType;
            OldRowId    = oldRowId;
            NewRow      = newRow;
        }
Ejemplo n.º 18
0
        public CreateTriggerStatement(ObjectName triggerName, ObjectName tableName, PlSqlBlockStatement body, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
            {
                throw new ArgumentNullException("triggerName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }
            if (body == null)
            {
                throw new ArgumentNullException("body");
            }

            TriggerName = triggerName;
            TableName   = tableName;
            Body        = body;
            EventTime   = eventTime;
            EventType   = eventType;
        }
Ejemplo n.º 19
0
        public CreateProcedureTriggerStatement(ObjectName triggerName, ObjectName tableName, ObjectName procedureName, InvokeArgument[] args, TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (triggerName == null)
            {
                throw new ArgumentNullException("triggerName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }
            if (procedureName == null)
            {
                throw new ArgumentNullException("procedureName");
            }

            TriggerName        = triggerName;
            TableName          = tableName;
            ProcedureName      = procedureName;
            ProcedureArguments = args;
            EventTime          = eventTime;
            EventType          = eventType;
        }
Ejemplo n.º 20
0
 private void OnTableEvent(TriggerEventTime eventTime, TriggerEventType eventType, RowId rowId, Row row)
 {
     Request.Access().FireTriggers(Request, new TableEvent(this, eventTime, eventType, rowId, row));
 }
        public override SqlStatement VisitCreateTriggerStatement(PlSqlParser.CreateTriggerStatementContext context)
        {
            var triggerName = Name.Object(context.objectName());
            var orReplace   = context.OR() != null && context.REPLACE() != null;

            TriggerStatus status = TriggerStatus.Unknown;

            if (context.DISABLE() != null)
            {
                status = TriggerStatus.Disabled;
            }
            else if (context.ENABLE() != null)
            {
                status = TriggerStatus.Enabled;
            }

            var simpleDml = context.simpleDmlTrigger();

            ObjectName       onObject  = null;
            TriggerEventType eventType = new TriggerEventType();
            TriggerEventTime eventTime = new TriggerEventTime();

            if (simpleDml != null)
            {
                bool before = simpleDml.BEFORE() != null;
                bool after  = simpleDml.AFTER() != null;

                var events = simpleDml.dmlEventClause().dmlEventElement().Select(x => {
                    if (x.DELETE() != null)
                    {
                        return(TriggerEventType.Delete);
                    }
                    if (x.UPDATE() != null)
                    {
                        return(TriggerEventType.Update);
                    }
                    if (x.INSERT() != null)
                    {
                        return(TriggerEventType.Insert);
                    }

                    throw new InvalidOperationException();
                });

                foreach (var type in events)
                {
                    eventType |= type;
                }

                if (before)
                {
                    eventTime = TriggerEventTime.Before;
                }
                else if (after)
                {
                    eventTime = TriggerEventTime.After;
                }

                onObject = Name.Object(simpleDml.dmlEventClause().objectName());
            }

            var triggerBody = context.triggerBody();

            if (triggerBody.triggerBlock() != null)
            {
                var declarations = triggerBody.triggerBlock().declaration().Select(Visit);
                var body         = (PlSqlBody)Visit(triggerBody.triggerBlock().body());

                var plsqlBody = body.AsPlSqlStatement();
                foreach (var declaration in declarations)
                {
                    plsqlBody.Declarations.Add(declaration);
                }

                return(new CreateTriggerStatement(triggerName, onObject, plsqlBody, eventTime, eventType)
                {
                    ReplaceIfExists = orReplace,
                    Status = status
                });
            }

            var procName = Name.Object(triggerBody.objectName());
            var args     = new InvokeArgument[0];

            if (triggerBody.function_argument() != null)
            {
                args = triggerBody.function_argument()
                       .argument()
                       .Select(FunctionArgument.Form)
                       .Select(x => new InvokeArgument(x.Id, x.Expression))
                       .ToArray();
            }

            return(new CreateProcedureTriggerStatement(triggerName, onObject, procName, args, eventTime, eventType)
            {
                ReplaceIfExists = orReplace,
                Status = status
            });
        }
Ejemplo n.º 22
0
 public CallbackTriggerInfo(string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
     : base(new ObjectName(triggerName), TriggerType.Callback, tableName, eventTime, eventType)
 {
 }
Ejemplo n.º 23
0
 public static void CreateTrigger(this IQuery query, ObjectName triggerName, ObjectName tableName, PlSqlBlockStatement body, TriggerEventTime eventTime, TriggerEventType eventType)
 {
     query.ExecuteStatement(new CreateTriggerStatement(triggerName, tableName, body, eventTime, eventType));
 }
Ejemplo n.º 24
0
 public void CreateCallbackTrigger(string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
 {
     Session.Context.DeclareTrigger(new CallbackTriggerInfo(triggerName, tableName, eventTime, eventType));
 }
Ejemplo n.º 25
0
 public static void CreateCallbackTrigger(this IQuery query, string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
 {
     query.ExecuteStatement(new CreateCallbackTriggerStatement(triggerName, tableName, eventTime, eventType));
 }
Ejemplo n.º 26
0
 public static void CreateProcedureTrigger(this IQuery query, ObjectName triggerName, ObjectName tableName,
                                           ObjectName procedureName,
                                           TriggerEventTime eventTime, TriggerEventType eventType)
 {
     CreateProcedureTrigger(query, triggerName, tableName, procedureName, new InvokeArgument[0], eventTime, eventType);
 }
Ejemplo n.º 27
0
        private bool MatchesEvent(TriggerEventTime eventTime, TriggerEventType eventType)
        {
            if (eventTime != EventTime)
                return false;

            return (EventType & eventType) != 0;
        }
Ejemplo n.º 28
0
 public ProcedureTriggerInfo(ObjectName triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType, ObjectName procedureName)
     : this(triggerName, tableName, eventTime, eventType, procedureName, new InvokeArgument[0])
 {
 }
Ejemplo n.º 29
0
 public ProcedureTriggerInfo(ObjectName triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType, ObjectName procedureName)
     : this(triggerName, tableName, eventTime, eventType, procedureName, new InvokeArgument[0])
 {
 }
 public CreateProcedureTriggerStatement(ObjectName triggerName, ObjectName tableName, ObjectName procedureName, TriggerEventTime eventTime, TriggerEventType eventType)
     : this(triggerName, tableName, procedureName, new InvokeArgument[0], eventTime, eventType)
 {
 }
Ejemplo n.º 31
0
 public CreateProcedureTriggerStatement(ObjectName triggerName, ObjectName tableName, ObjectName procedureName, TriggerEventTime eventTime, TriggerEventType eventType)
     : this(triggerName, tableName, procedureName, new InvokeArgument[0], eventTime, eventType)
 {
 }
Ejemplo n.º 32
0
 private static string FormMessage(ObjectName tableName, ObjectName triggerName, TriggerEventTime eventTime, TriggerEventType eventType)
 {
     return String.Format("An error occurred when firing trigger '{0}' {1} {2} on table '{3}'",
         triggerName, eventTime, eventType, tableName);
 }
Ejemplo n.º 33
0
 private static string FormMessage(ObjectName tableName, ObjectName triggerName, TriggerEventTime eventTime, TriggerEventType eventType)
 {
     return(String.Format("An error occurred when firing trigger '{0}' {1} {2} on table '{3}'",
                          triggerName, eventTime, eventType, tableName));
 }
Ejemplo n.º 34
0
 private void OnTableEvent(TriggerEventTime eventTime, TriggerEventType eventType, RowId rowId, Row row)
 {
     Request.Access().FireTriggers(Request, new TableEvent(this, eventTime, eventType, rowId, row));
 }
 public CallbackTriggerInfo(string triggerName, ObjectName tableName, TriggerEventTime eventTime, TriggerEventType eventType)
     : base(new ObjectName(triggerName), TriggerType.Callback, tableName, eventTime, eventType)
 {
 }