Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
?-- =============================================
-- Description: Backfill (FK)s in the raw TIUDocuments table
--
-- Maintenance Log:
--
-- Update By Update Date Description
-- Jayme --------- ----------------------------
-- =============================================
CREATE PROCEDURE zraw.[uspDoSynchRawFKTIUDocuments]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @batchTable TABLE
(
BatchLogID bigint Primary Key,
TableName varchar (50),
BatchDate datetime2(7)
)
BEGIN TRY
--need to restrict the records we modified to only those available for internalprocessing
INSERT INTO @batchTable (BatchLogID, TableName, BatchDate)
SELECT * FROM dbo.ufnGetBatchLogBatchDate ('INTPROCESSING', null)
--Backfill the RecordStatusID based on OpCode
UPDATE zraw._TIUTIUDocuments SET
RecordStatusID = RecordStatuses.RecordStatusID
FROM RecordStatuses
INNER JOIN zraw._TIUTIUDocuments ON RecordStatuses.RecordStatusCode = zraw._TIUTIUDocuments.OpCode;
--Backfill the TIUDocumentDefinitionID
UPDATE zraw._TIUTIUDocuments SET
TIUDocumentDefinitionID = TIUDocumentDefinitions.TIUDocumentDefinitionID
FROM TIUDocumentDefinitions
INNER JOIN zraw._TIUTIUDocuments ON zraw._TIUTIUDocuments.TIUDocumentDefinitionIEN = TIUDocumentDefinitions.TIUDocumentDefinitionIEN
AND zraw._TIUTIUDocuments.StationID = TIUDocumentDefinitions.StationID
INNER JOIN @batchTable bt ON zraw._TIUTIUDocuments.BATCHLOGID = bt.BatchLogID;
--TODO: Add the rest of the (FK)s
END TRY
BEGIN CATCH
PRINT 'There was an error synchronizing OneConsult Stations Type data' + CHAR(13);
THROW;
END CATCH
END
GO