Jobs: truncate table before 'clearbeforefill'
This commit is contained in:
parent
f3eef04a09
commit
8362e1885d
@ -119,17 +119,21 @@ Public Class GraphQLJob
|
||||
|
||||
' Clear Table before inserting
|
||||
If pQuery.ClearBeforeFill = True Then
|
||||
If DeleteWithQueryName(pQuery) = False Then
|
||||
If DeleteHistoryTable(pQuery) = False Then
|
||||
Throw New ApplicationException($"Error while dropping history table before fill for Query [{pQuery.Name}]")
|
||||
End If
|
||||
|
||||
If CreateHistoryTable(pQuery) = False Then
|
||||
Throw New ApplicationException($"Error while creating history table before fill for Query [{pQuery.Name}]")
|
||||
End If
|
||||
|
||||
If TruncateTable(pQuery) = False Then
|
||||
Throw New ApplicationException($"Error while truncating table before fill for Query [{pQuery.Name}]")
|
||||
End If
|
||||
End If
|
||||
|
||||
' Reset all records to status = 0
|
||||
If pQuery.ClearBeforeFill = False Then
|
||||
' Reset all records to status = 0
|
||||
If pQuery.ClearBeforeFill = False Then
|
||||
_Logger.Info("Resetting data for Query [{0}]", pQuery.Name)
|
||||
If UpdateWithStatus(pQuery, 0) = False Then
|
||||
Throw New ApplicationException($"Error while resetting status of current Records for Query [{pQuery.Name}]")
|
||||
@ -200,7 +204,7 @@ Public Class GraphQLJob
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function DeleteWithQueryName(pQuery As GraphQL.Query) As Boolean
|
||||
Private Function DeleteHistoryTable(pQuery As Query) As Boolean
|
||||
Dim oHistoryTableName = $"{pQuery.DestinationTable}_HISTORY"
|
||||
Dim oDeleteHistorySQL = $"
|
||||
IF (EXISTS (SELECT *
|
||||
@ -214,6 +218,12 @@ Public Class GraphQLJob
|
||||
Return _MSSQL.ExecuteNonQuery(oDeleteHistorySQL)
|
||||
End Function
|
||||
|
||||
Private Function TruncateTable(pQuery As Query)
|
||||
Dim oDeleteTableSQL = $"TRUNCATE TABLE {pQuery.DestinationTable}"
|
||||
|
||||
Return _MSSQL.ExecuteNonQuery(oDeleteTableSQL)
|
||||
End Function
|
||||
|
||||
Private Function CreateHistoryTable(pQuery As Query) As Boolean
|
||||
Dim oHistoryTableName = $"{pQuery.DestinationTable}_HISTORY"
|
||||
Dim oFillHistorySQL = $"SELECT * INTO {oHistoryTableName} FROM {pQuery.DestinationTable}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user