📄 netmanage.dm1
字号:
End Function
",0
52,"Function SSDefChInsRstr( Rel As Relationship, TriggerName As String ) As String
Dim Result As String
Dim WhereFrag As String
Dim FKColumn As FKColumnPair
ParentCount% = 0
ChildCount% = 0
For Each FKColumn In Rel.FKColumnPairs
If FKColumn.ParentAttribute.Hidden = False Then ParentCount = ParentCount + 1
If FKColumn.ChildAttribute.Hidden = False Then ChildCount = ChildCount + 1
If ParentCount <> ChildCount Then Exit Function
Next FKColumn
Result = ""-- Child Insert: RESTRICT"" & vbCrLf & vbCrLf
If Rel.Mandatory Then
Result = Result & "" IF ((SELECT COUNT(*)"" & vbCrLf
Result = Result & "" FROM "" & Rel.ParentEntity.TableName & "" pr, inserted"" & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & ""pr."" & FKColumn.ParentAttribute.ColumnName
Result = Result & "" = inserted."" & FKColumn.ChildAttribute.ColumnName
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" AND"" & vbCrLf & "" ""
Else
Result = Result & "") != @Rows)"" & vbCrLf
End If
Next FKColumn
Else
Result = Result & "" SELECT @NullRows = COUNT(*)"" & vbCrLf
Result = Result & "" FROM inserted"" & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
NeedAnd% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
If WhereFrag <> """" Then
Result = Result & WhereFrag
WhereFrag = """"
If FKColumn.ChildAttribute.PrimaryKey Then
NeedAnd% = 1
Else
Result = Result & "" AND"" & vbCrLf & "" ""
NeedAnd% = 0
End If
End If
If FKColumn.ChildAttribute.PrimaryKey Then
Else
WhereFrag = "" inserted."" & FKColumn.ChildAttribute.ColumnName & "" IS NULL""
End If
If Count% = Rel.FKColumnPairs.Count Then
If WhereFrag <> """" Then
If NeedAnd% Then
Result = Result & "" AND"" & vbCrLf & "" ""
End If
Result = Result & WhereFrag & vbCrLf & vbCrLf
Else
If NeedAnd% Then
Result = Result & vbCrLf
End If
Result = Result & vbCrLf
End If
End If
Next FKColumn
Result = Result & "" SELECT @ValidRows = COUNT(*)"" & vbCrLf
Result = Result & "" FROM "" & Rel.ParentEntity.TableName & "" pr, inserted"" & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & ""pr."" & FKColumn.ParentAttribute.ColumnName
Result = Result & "" = inserted."" & FKColumn.ChildAttribute.ColumnName
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" AND"" & vbCrLf & "" ""
Else
Result = Result & vbCrLf & vbCrLf
End If
Next FKColumn
Result = Result & "" IF (@NullRows + @ValidRows <> @Rows)"" & vbCrLf
End If
Result = Result & "" BEGIN"" & vbCrLf & "" RAISERROR 30000 '"" & TriggerName
Result = Result & ""Cannot insert because primary key value not found in ""
Result = Result & Rel.ParentEntity.TableName & ""'"" & vbCrLf
Result = Result & "" ROLLBACK TRAN"" & vbCrLf
Result = Result & "" END"" & vbCrLf
SSDefChInsRstr = Result
End Function
",0
54,"
'Basic function that generates update trigger for SQL Server and Sybase
'This trigger code is the same as that generated by ERStudio 3.5
Sub Main
Dim Result As String
Dim Attr As AttributeObj
Dim PkDtype As String
'Standard trigger body beginning for update action
Result = ""CREATE TRIGGER "" & TriggerName & "" ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""FOR UPDATE AS"" & vbCrLf & ""BEGIN"" & vbCrLf & "" DECLARE"" & vbCrLf
For Each Attr In CurrEntity.Attributes
If Attr.PrimaryKey Then
If Attr.Hidden = False Then
PkDtype = Attr.CompositeDatatype
PkDtype = Replace(PkDtype, ""NULL"", """")
PkDtype = Replace(PkDtype, ""NOT"", """")
PkDtype = RTrim(PkDtype)
Result = Result & "" @"" & Attr.ColumnName & "" "" & PkDtype & "","" & vbCrLf
End If
End If
Next Attr
Result = Result & "" @Rows int,"" & vbCrLf
Result = Result & "" @NullRows int,"" & vbCrLf
Result = Result & "" @ValidRows int"" & vbCrLf & vbCrLf
Result = Result & "" SELECT @Rows = @@rowcount"" &vbCrLf & "" IF @Rows = 0"" & vbCrLf
Result = Result & "" RETURN"" & vbCrLf & vbCrLf
'Emit the trigger code for each parent and child relationship for this table
Dim Rel As Relationship
Dim Action As String
For Each Rel In CurrEntity.ParentRelationships
Action = Rel.ParentAction(""UPDATE"")
If Action = ""RESTRICT"" Then
Result = Result & SSDefParUpdtRstr(Rel, TriggerName)
ElseIf Action = ""CASCADE"" Then
Result = Result & SSDefParUpdtCasc(Rel)
ElseIf Action = ""SETNULL"" Then
Result = Result & SSDefParUpdtSN(Rel)
End If
Next Rel
For Each Rel In CurrEntity.ChildRelationships
Action = Rel.ChildAction(""UPDATE"")
If Action = ""RESTRICT"" Then
Result = Result & SSDefChUpdtRstr(Rel, TriggerName)
End If
Next Rel
'Standard trigger body end for update action
Result = Result & vbCrLf & ""END"" & vbCrLf & ""go"" & vbCrLf
'Display result in message box (remove ' from line below)
'MsgBox(Result)
ResultString = Result
End Sub
",0
56,"
'Basic function that generates delete trigger for SQL Server and Sybase
'This trigger code is the same as that generated by ERStudio 3.5
Sub Main
Dim Result As String
Dim Attr As AttributeObj
'Standard trigger body beginning for delete action
Result = ""CREATE TRIGGER "" & TriggerName & "" ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""FOR DELETE AS"" & vbCrLf & ""BEGIN"" & vbCrLf & "" DECLARE"" & vbCrLf
Result = Result & "" @Rows int"" & vbCrLf & vbCrLf
Result = Result & "" SELECT @Rows = @@rowcount"" &vbCrLf & "" IF @Rows = 0"" & vbCrLf
Result = Result & "" RETURN"" & vbCrLf & vbCrLf
'Emit the trigger code for each parent relationship for this table
Dim Rel As Relationship
Dim Action As String
For Each Rel In CurrEntity.ParentRelationships
Action = Rel.ParentAction(""DELETE"")
If Action = ""RESTRICT"" Then
Result = Result & SSDefParDelRstr(Rel, TriggerName)
ElseIf Action = ""CASCADE"" Then
Result = Result & SSDefParDelCasc(Rel)
ElseIf Action = ""SETNULL"" Then
Result = Result & SSDefParDelSN(Rel)
End If
Next Rel
'Standard delete trigger does nothing on child delete
'Standard trigger body end for delete action
Result = Result & vbCrLf & ""END"" & vbCrLf & ""go"" & vbCrLf
'Display result in message box (remove ' from line below)
'MsgBox(Result)
ResultString = Result
End Sub
",0
58,"
'Basic function that generates insert trigger for SQL Server and Sybase
'This trigger code is the same as that generated by ERStudio 3.5
Sub Main
Dim Result As String
Dim Attr As AttributeObj
'Standard trigger body beginning for insert action
Result = ""CREATE TRIGGER "" & TriggerName & "" ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""FOR INSERT AS"" & vbCrLf & ""BEGIN"" & vbCrLf & "" DECLARE"" & vbCrLf
Result = Result & "" @Rows int,"" & vbCrLf
Result = Result & "" @NullRows int,"" & vbCrLf
Result = Result & "" @ValidRows int"" & vbCrLf & vbCrLf
Result = Result & "" SELECT @Rows = @@rowcount"" &vbCrLf & "" IF @Rows = 0"" & vbCrLf
Result = Result & "" RETURN"" & vbCrLf & vbCrLf
'Emit the trigger code for each child relationship for this table
Dim Rel As Relationship
Dim Action As String
For Each Rel In CurrEntity.ChildRelationships
Action = Rel.ChildAction(""INSERT"")
If Action = ""RESTRICT"" Then
Result = Result & SSDefChInsRstr(Rel, TriggerName)
End If
Next Rel
'Standard trigger body end for insert action
Result = Result & vbCrLf & ""END"" & vbCrLf & ""go"" & vbCrLf
'Display result in message box (remove ' from line below)
'MsgBox(Result)
ResultString = Result
End Sub
",0
48,"
Function SSDefParUpdtSN( Rel As Relationship ) As String
Dim Result As String
Dim FKColumn As FKColumnPair
ParentCount% = 0
ChildCount% = 0
For Each FKColumn In Rel.FKColumnPairs
If FKColumn.ParentAttribute.Hidden = False Then ParentCount = ParentCount + 1
If FKColumn.ChildAttribute.Hidden = False Then ChildCount = ChildCount + 1
if ParentCount <> ChildCount Then Exit Function
Next FKColumn
Result = ""-- Parent Update: SET NULL"" & vbCrLf & vbCrLf
Result = Result & "" IF (""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & ""UPDATE("" & FKColumn.ParentAttribute.ColumnName & "")""
If Count < Rel.FKColumnPairs.Count Then
Result = Result & "" OR"" & vbCrLf & "" ""
Else
Result = Result & "")"" & vbCrLf & "" BEGIN"" & vbCrLf
End If
Next FKColumn
Result = Result & "" UPDATE "" & Rel.ChildEntity.TableName & "" SET"" & vbCrLf
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & "" "" & FKColumn.ChildAttribute.ColumnName & "" = NULL""
If Count < Rel.FKColumnPairs.Count Then Result = Result & "",""
Result = Result & vbCrLf
Next FKColumn
Result = Result & "" FROM "" & Rel.ChildEntity.TableName
Result = Result & "" ch, deleted"" & vbCrLf & "" WHERE"" & vbCrLf
Count% = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -