graphql: create history table before running
This commit is contained in:
parent
dc6ad9afac
commit
6e5b192fb6
@ -120,7 +120,11 @@ Public Class GraphQLJob
|
||||
' Clear Table before inserting
|
||||
If pQuery.ClearBeforeFill = True Then
|
||||
If DeleteWithQueryName(pQuery) = False Then
|
||||
Throw New ApplicationException($"Error while clearing table before fill for Query [{pQuery.Name}]")
|
||||
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
|
||||
End If
|
||||
|
||||
@ -196,12 +200,28 @@ Public Class GraphQLJob
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function DeleteWithQueryName(pQuery)
|
||||
Dim oDeleteSQL = $"TRUNCATE TABLE {pQuery.DestinationTable}"
|
||||
Return _MSSQL.ExecuteNonQuery(oDeleteSQL)
|
||||
Private Function DeleteWithQueryName(pQuery As GraphQL.Query) As Boolean
|
||||
Dim oHistoryTableName = $"{pQuery.DestinationTable}_HISTORY"
|
||||
Dim oDeleteHistorySQL = $"
|
||||
IF (EXISTS (SELECT *
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = 'dbo'
|
||||
AND TABLE_NAME = '{oHistoryTableName}'))
|
||||
BEGIN
|
||||
DROP TABLE {oHistoryTableName};
|
||||
END"
|
||||
|
||||
Return _MSSQL.ExecuteNonQuery(oDeleteHistorySQL)
|
||||
End Function
|
||||
|
||||
Private Function DeleteWithStatus(pQuery As Query, pStatus As Integer)
|
||||
Private Function CreateHistoryTable(pQuery As Query) As Boolean
|
||||
Dim oHistoryTableName = $"{pQuery.DestinationTable}_HISTORY"
|
||||
Dim oFillHistorySQL = $"SELECT * INTO {oHistoryTableName} FROM {pQuery.DestinationTable}"
|
||||
|
||||
Return _MSSQL.ExecuteNonQuery(oFillHistorySQL)
|
||||
End Function
|
||||
|
||||
Private Function DeleteWithStatus(pQuery As Query, pStatus As Integer) As Boolean
|
||||
Dim oDeleteSQL = $"DELETE FROM {pQuery.DestinationTable} WHERE STATUS = {pStatus} AND ADDED_QUERY_ID = '{pQuery.Id}'"
|
||||
Return _MSSQL.ExecuteNonQuery(oDeleteSQL)
|
||||
End Function
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user