open-insight/LSL2/STPROC/COPY_TUBE_RECORD_TO_SQL.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

54 lines
2.0 KiB
Plaintext

Compile function Copy_TUBE_Record_To_SQL(Connection, Key, Record)
/*****************************************************************************\
Copies the given TUBE record to the MSSQL database.
History
-------
06/28/2010 KRF Original Programmer
\*****************************************************************************/
$insert TUBE_EQUATES
Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""
// Parse record into a dimensioned array for speed
Dim Rec(14)
MatParse Record into Rec
// List of key names and their values
Keys = "TUBE_ID":@VM:SQL_Format(Key, "STR")
// List of data fields and their values
DataFields = "[DESC]":@VM:SQL_Format(Rec(1), "STR"):@FM
DataFields := "STATUS":@VM:SQL_Format(Rec(TUBE_STATUS$), "STR"):@FM
DataFields := "NOTES" :@VM:SQL_Format(Rec(TUBE_NOTES$), "STR")
// Write the data to the SQL database
Ans = SQL_Write(Connection, "TUBE", Keys, DataFields)
//-------------------------------------------------------------------------------------------------
// Multi-valued Fields
// TUBE_REACT_NO
If Ans EQ "" AND Rec(4) NE "" then
// List of data fields and their values
MvFields = "REACT_NO" :@FM:SQL_Format(Rec(4), "STR"):@RM
MvFields := "INST_DTM" :@FM:SQL_Format(Rec(5), "DATETIME"):@RM
MvFields := "INST_REACT_HRS" :@FM:SQL_Format(Rec(6), "INT"):@RM
MvFields := "INST_REACT_CYCLES":@FM:SQL_Format(Rec(7), "STR"):@RM
MvFields := "INST_RL_ID" :@FM:SQL_Format(Rec(8), "STR"):@RM
MvFields := "RDS_WFR_CNT" :@FM:SQL_Format(Rec(9), "INT"):@RM
MvFields := "REM_DTM" :@FM:SQL_Format(Rec(10), "DATETIME"):@RM
MvFields := "REM_REACT_HRS" :@FM:SQL_Format(Rec(11), "INT"):@RM
MvFields := "REM_REACT_CYCLES" :@FM:SQL_Format(Rec(12), "STR"):@RM
MvFields := "REM_RL_ID" :@FM:SQL_Format(Rec(13), "STR")
// Write the data to the SQL database
Ans = SQL_Write_MV(Connection, "TUBE_REACT_NO", Keys, MvFields);
end
Return Ans