DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
TriggerBody.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections.Generic;
19 
21 
22 namespace Deveel.Data.Sql.Triggers {
23  public sealed class TriggerBody {
24  private readonly List<SqlStatement> statements;
25 
26  internal TriggerBody(TriggerInfo triggerInfo) {
27  if (triggerInfo == null)
28  throw new ArgumentNullException("triggerInfo");
29 
30  TriggerInfo = triggerInfo;
31 
32  statements = new List<SqlStatement>();
33  }
34 
35  public TriggerInfo TriggerInfo { get; private set; }
36 
37  private void AssertStatementIsAllowed(SqlStatement statement) {
38  // TODO: validate this statement
39  }
40 
41 
42  public void AddStatement(SqlStatement statement) {
43  if (statement == null)
44  throw new ArgumentNullException("statement");
45 
46  if (TriggerInfo.TriggerType != TriggerType.Procedure)
47  throw new ArgumentException(String.Format("The trigger '{0}' is not a PROCEDURE TRIGGER and cannot have any body.",
49 
50  AssertStatementIsAllowed(statement);
51 
52  statements.Add(statement);
53  }
54  }
55 }
Defines the information about a trigger on a table of the database, such as the event on which is fir...
Definition: TriggerInfo.cs:29
void AddStatement(SqlStatement statement)
Definition: TriggerBody.cs:42
TriggerBody(TriggerInfo triggerInfo)
Definition: TriggerBody.cs:26
Represents the foundation class of SQL statements to be executed.
Definition: SqlStatement.cs:32
ObjectName TriggerName
Gets the fully qualified name of the trigger.
Definition: TriggerInfo.cs:78
readonly List< SqlStatement > statements
Definition: TriggerBody.cs:24
TriggerType
Enumerates the types of triggers, that can be volatile (like the Callback) or stored in the database...
Definition: TriggerType.cs:22
void AssertStatementIsAllowed(SqlStatement statement)
Definition: TriggerBody.cs:37
TriggerType TriggerType
Gets the type of trigger.
Definition: TriggerInfo.cs:90