Compile function Copy_REACT_TUBE_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given REACT_TUBE record to the MSSQL database.
	
	History
	-------
	08/06/2010    KRF   Original Programmer
\*****************************************************************************/

$insert REACT_TUBE_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

// Parse record into a dimensioned array for speed
Dim Rec(12)
MatParse Record into Rec
					    
// List of key names and their values
Keys = "REACT_NO":@VM:SQL_Format(Key, "INT")

// Write the data to the SQL database
Ans = SQL_Write(Connection, "REACT_TUBE", Keys, DataFields)

//-------------------------------------------------------------------------------------------------
// Multi-valued Fields

// REACT_TUBE_DETAIL
If Ans EQ "" AND Rec(REACT_TUBE_TUBE_ID$) NE "" then
    
    // List of data fields and their values
    MvFields  = "TUBE_ID"          :@FM:SQL_Format(Rec(REACT_TUBE_TUBE_ID$),           "STR"):@RM
    MvFields := "RDS_WAFER_CNT"    :@FM:SQL_Format(Rec(REACT_TUBE_RDS_WAFER_CNT$),     "INT"):@RM
    MvFields := "INST_DTM"         :@FM:SQL_Format(Rec(REACT_TUBE_INST_DTM$),          "DATETIME"):@RM
    MvFields := "INST_REACT_HRS"   :@FM:SQL_Format(Rec(REACT_TUBE_INST_REACT_HRS$),    "INT"):@RM
    MvFields := "INST_REACT_CYCLES":@FM:SQL_Format(Rec(REACT_TUBE_INST_REACT_CYCLES$), "STR"):@RM
    MvFields := "INST_RL_ID"       :@FM:SQL_Format(Rec(REACT_TUBE_INST_RL_ID$),        "STR"):@RM
    MvFields := "REM_DTM"          :@FM:SQL_Format(Rec(REACT_TUBE_REM_DTM$),           "DATETIME"):@RM
    MvFields := "REM_REACT_HRS"    :@FM:SQL_Format(Rec(REACT_TUBE_REM_REACT_HRS$),     "INT"):@RM
    MvFields := "REM_REACT_CYCLES" :@FM:SQL_Format(Rec(REACT_TUBE_REM_REACT_CYCLES$),  "STR"):@RM
    MvFields := "REM_RL_ID"        :@FM:SQL_Format(Rec(REACT_TUBE_REM_RL_ID$),         "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "REACT_TUBE_DETAIL", Keys, MvFields);
    
end

Return Ans
