open-insight/LSL2/STPROC/PASS_TO_SQL.txt
2024-03-25 14:46:21 -07:00

76 lines
2.9 KiB
Plaintext

Compile Subroutine Pass_To_SQL(Process, Table, ID)
/*****************************************************************************\
Passes updated OI data to SQL from the SQL_MFS procedure
History
-------
06/10/2010 PCS Original Programmer
07/18/2018 dmb Disable call to SRP_TcpClient/SRP Engine Server since this can't be processed by the
Application Server.
\*****************************************************************************/
$insert SRPMAIL_INSERTS
Common /PASS_TO_SQL/ TCPServerSettings@
Declare Function SRP_TcpClient, DateTime, Get.RecCount, Environment_Services, Database_Services, Ucase
Declare Subroutine SRP_TcpClient
If Assigned(Process) else Process = ""
If Assigned(ID) else ID = ""
If Assigned(Table) else Table = ""
NonCriticalTables = Database_Services('ReadDataRow', 'APP_INFO', 'NONCRITICAL_SQL_TABLES')
If Process AND ID AND Table then
! Old code from before the APP/DB EC split. --------------- !
// Set the Command to run based upon the MFS Call. Currently only Write is enabled
* Begin Case
* Case Process _EQC "Write"
* Command = "RUN COPY_RECORD_TO_SQL ":Quote(Table):", ":Quote(ID):", 1"
* Case Process _EQC "Delete"
* Command = "RUN DELETE_RECORD_FROM_SQL ":Quote(Table):", ":Quote(ID):", 1"
* Case 1
* Command = ""
* End Case
*
* If Command then
// Disable call to SRP_TcpClient/SRP Engine Server since this can't be processed by the Application Server. - dmb - 07/18/2018
// Call the SRPEngineService and pass it the command
* Server = Environment_Services('GetServer')
* TCPServerSettings@ = Database_Services('ReadDataRow', 'APP_INFO', 'SQL_TCPIP_SETTINGS_' : Server)
* TcpClientHandle = 0
* If SRP_TcpClient(TcpClientHandle, "CONNECT", TCPServerSettings@<1>, TCPServerSettings@<2>) then
* SRP_TcpClient(TcpClientHandle, "SEND_SES", Command)
* SRP_TcpClient(TcpClientHandle, "CLOSE_SES")
* end
! ---------------------------------------------------------- !
// Unable to issue the remote command, so log this record as needing to be copied
Open "SQL_BACKLOG" to hSqlBacklog then
CurrDate = Date()
// Log the record
Locate Table in NonCriticalTables using @FM setting Dummy then
bKey = Table:"*":ID:"*":UCase(Process)
end else
CurrTime = Time()
bKey = Table:"*":ID:"*":UCase(Process):'*':CurrDate:'*':CurrTime
end
Write DateTime() to hSqlBacklog, bKey
!! Always log it for redudancy. !!
Open "SQL_LOG" to hSqlLog then
Read Log from hSqlLog, CurrDate then
Log := @FM:bKey:@VM:'QUEUED'
end else
Log = bKey:@VM:'QUEUED'
end
Write Log to hSqlLog, CurrDate
end
end
end
Return