📄 suncms.dm1.svn-base
字号:
OraDefChUpdtRstr = Result
End Function
",0
104,"
Function OraDefParDelSN( Rel As Relationship ) As String
Dim ParentEntity As Entity
Dim ChildEntity As Entity
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 Delete: SET NULL"" & vbCrLf
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 & "" WHERE"" & vbCrLf
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & "" "" & FKColumn.ChildAttribute.ColumnName
Result = Result & "" = :OLD."" & FKColumn.ParentAttribute.ColumnName
If Count < Rel.FKColumnPairs.Count Then
Result = Result & "" AND""
Else
Result = Result & "";""
End If
Result = Result & vbCrLf
Next FKColumn
OraDefParDelSN = Result
End Function
Function OraDefParDelRstr( Rel As Relationship, TriggerName As String ) 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 Delete: RESTRICT"" & vbCrLf
Result = Result & "" SELECT COUNT(*) INTO RowCount"" & vbCrLf
Result = Result & "" FROM "" & Rel.ChildEntity.TableName & "" ch"" & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & ""ch."" & FKColumn.ChildAttribute.ColumnName
Result = Result & "" = :OLD."" & FKColumn.ParentAttribute.ColumnName
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" AND"" & vbCrLf & "" ""
Else
Result = Result & "";"" & vbCrLf
End If
Next FKColumn
Result = Result & "" IF (RowCount > 0) THEN"" & vbCrLf
Result = Result & "" BEGIN"" & vbCrLf & "" RAISE_APPLICATION_ERROR(-20012, '""
Result = Result & TriggerName & "": ""
Result = Result & ""Cannot delete because foreign keys still exist in ""
Result = Result & Rel.ChildEntity.TableName & ""');"" & vbCrLf
Result = Result & "" END;"" & vbCrLf & ""END IF;"" & vbCrLf
OraDefParDelRstr = Result
End Function
Function OraDefParDelCasc( 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 Delete: CASCADE"" & vbCrLf
Result = Result & "" DELETE FROM "" & Rel.ChildEntity.TableName & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & FKColumn.ChildAttribute.ColumnName
Result = Result & "" = :OLD."" & FKColumn.ParentAttribute.ColumnName
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" AND"" & vbCrLf & "" ""
Else
Result = Result & "";"" & vbCrLf
End If
Next FKColumn
OraDefParDelCasc = Result
End Function
",0
106,"
Function OraDefChInsRstr( Rel As Relationship, TriggerName As String ) 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 = ""-- Child Insert: RESTRICT"" & vbCrLf
Result = Result & "" SELECT COUNT(*) INTO RowCount"" & vbCrLf
Result = Result & "" FROM "" & Rel.ParentEntity.TableName & "" pr"" & vbCrLf
Result = Result & "" WHERE ""
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
Result = Result & ""pr."" & FKColumn.ParentAttribute.ColumnName
Result = Result & "" = :NEW."" & FKColumn.ChildAttribute.ColumnName
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" AND"" & vbCrLf & "" ""
Else
Result = Result & "";"" & vbCrLf & vbCrLf
End If
Next FKColumn
If Rel.Mandatory Then
Result = Result & "" IF (RowCount < 1) THEN"" & vbCrLf
Else
Result = Result & "" IF (RowCount < 1 AND"" & vbCrLf
Count% = 0
For Each FKColumn In Rel.FKColumnPairs
Count% = Count% + 1
If Count% = 1 Then
Result = Result & "" (""
Else
Result = Result & "" ""
End If
Result = Result & "":NEW."" & FKColumn.ChildAttribute.ColumnName
Result = Result & "" IS NOT NULL""
If Count% < Rel.FKColumnPairs.Count Then
Result = Result & "" OR"" & vbCrLf
Else
Result = Result & ""))"" & vbCrLf & "" THEN"" & vbCrLf
End If
Next FKColumn
End If
Result = Result & "" BEGIN"" & vbCrLf & "" RAISE_APPLICATION_ERROR(-20000, '""
Result = Result & TriggerName & "": ""
Result = Result & ""Cannot insert because primary key value not found in ""
Result = Result & Rel.ParentEntity.TableName & ""');"" & vbCrLf
Result = Result & "" END;"" & vbCrLf
Result = Result & "" END IF;"" & vbCrLf
OraDefChInsRstr = Result
End Function
",0
108,"
'Basic function that generates update trigger for Oracle
'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 update action
Result = ""CREATE OR REPLACE TRIGGER "" & TriggerName
Result = Result & "" BEFORE UPDATE ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""REFERENCING OLD AS OLD NEW AS NEW"" & vbCrLf
Result = Result & ""FOR EACH ROW"" & vbCrLf
Result = Result & "" DECLARE RowCount NUMBER;"" & vbCrLf
Result = Result & ""BEGIN"" & 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(""UPDATE"")
If Action = ""RESTRICT"" Then
Result = Result & OraDefParUpdtRstr(Rel, TriggerName)
ElseIf Action = ""CASCADE"" Then
Result = Result & OraDefParUpdtCasc(Rel)
ElseIf Action = ""SETNULL"" Then
Result = Result & OraDefParUpdtSN(Rel)
End If
Next Rel
For Each Rel In CurrEntity.ChildRelationships
Action = Rel.ChildAction(""UPDATE"")
If Action = ""RESTRICT"" Then
Result = Result & OraDefChUpdtRstr(Rel, TriggerName)
End If
Next Rel
'Standard trigger body end for update action
Result = Result & vbCrLf & ""END;"" & vbCrLf
'Display result in message box (remove ' from line below)
'MsgBox(Result)
'Assign result SQL to external string for execution
ResultString = Result
End Sub
",0
110,"
'Basic function that generates delete trigger for Oracle
'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 OR REPLACE TRIGGER "" & TriggerName
Result = Result & "" BEFORE DELETE ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""REFERENCING OLD AS OLD NEW AS NEW"" & vbCrLf
Result = Result & ""FOR EACH ROW"" & vbCrLf
Result = Result & "" DECLARE RowCount NUMBER;"" & vbCrLf
Result = Result & ""BEGIN"" & 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 & OraDefParDelRstr(Rel, TriggerName)
ElseIf Action = ""CASCADE"" Then
Result = Result & OraDefParDelCasc(Rel)
ElseIf Action = ""SETNULL"" Then
Result = Result & OraDefParDelSN(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
'Display result in message box (remove ' from line below)
'MsgBox(Result)
'Assign result SQL to external string for execution
ResultString = Result
End Sub
",0
112,"
'Basic function that generates insert trigger for Oracle
'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 OR REPLACE TRIGGER "" & TriggerName
Result = Result & "" BEFORE INSERT ON "" & CurrEntity.TableName & vbCrLf
Result = Result & ""REFERENCING OLD AS OLD NEW AS NEW"" & vbCrLf
Result = Result & ""FOR EACH ROW"" & vbCrLf
Result = Result & "" DECLARE RowCount NUMBER;"" & vbCrLf
Result = Result & ""BEGIN"" & vbCrLf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -