Subroutine Write_OI_To_SQL(TransactionID) #pragma precomp SRP_PreCompiler $insert LOGICAL Declare function SQL_Services, Error_Services, Database_Services, Memory_Services, Environment_Services, Logging_Services Declare subroutine SQL_Services, Error_Services, Memory_Services, Attach_Table, Logging_Services If TransactionID NE '' then * (Action, AccountName, Volume, OITableName, OIKeyID) = TransactionID Action = TransactionID[1, @FM] If Action EQ 'WRITE' then AccountName = TransactionID[Col2() + 1, @FM] Volume = TransactionID[Col2() + 1, @FM] OITableName = TransactionID[Col2() + 1, @FM] OIKeyID = TransactionID[Col2() + 1, @FM] If OIKeyID NE '*' then OIRow = Database_Services('ReadDataRow', OITableName, OIKeyID) If Error_Services('NoError') then SQL_Services('WriteDataRowToSQL', OITableName, OIKeyID, OIRow) If Error_Services('HasError') then Message = Error_Services('GetMessage') * IF OITableName EQ 'RDS' then * LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Replication' * LogDate = Oconv(Date(), 'D4/') * LogTime = Oconv(Time(), 'MTS') * LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' WRITE_OI_Error.csv' * Headers = 'Logging DTM' : @FM : 'User' : @FM : 'Table' : @FM : 'Key' * objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$) * LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM * * ErrTitle = 'Error in ':OITableName * ErrorMsg = '' * * LogData = '' * LogData<1, 1> = LoggingDTM * LogData<1, 2> = @User4 * LogData<1, 3> = OITableName * LogData<1, 4> = OIKeyID * LogData<1, 5> = Message * Logging_Services('AppendLog', objLog, LogData, @FM, @VM) * end GoSub WriteLog Error_Services('Add', Message) end end else Message = Error_Services('GetMessage') GoSub WriteLog If IndexC(Message, 'Error reading', 1) AND IndexC(Message, 'Error = 100', 1) then // The error is due to a read error as the result of a missing record. Clear the error. Error_Services('Clear') end end end end end Return WriteLog: LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Replication' LogDate = Oconv(Date(), 'D4/') LogTime = Oconv(Time(), 'MTS') LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' WRITE_OI_Error.csv' Headers = 'Logging DTM' : @FM : 'User' : @FM : 'Table' : @FM : 'Key' objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$) LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM ErrTitle = 'Error in ':OITableName ErrorMsg = '' LogData = '' LogData<1, 1> = LoggingDTM LogData<1, 2> = @User4 LogData<1, 3> = OITableName LogData<1, 4> = OIKeyID LogData<1, 5> = Message Logging_Services('AppendLog', objLog, LogData, @FM, @VM) return