Compile function Copy_REACT_UTIL_Record_To_SQL(Connection, Key, Record)

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

$insert REACT_UTIL_EQU

Declare function SQL_Write, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "REACTOR"         :@VM:SQL_Format(Rec(REACT_UTIL_REACTOR$),                          "INT"):@FM
DataFields := "MODE"            :@VM:SQL_Format(OConv(Rec(REACT_UTIL_MODE$), "[REACT_MODE_CONV]"), "STR"):@FM
DataFields := "START_DATE"      :@VM:SQL_Format(Rec(REACT_UTIL_START_DATE$),                       "DATE"):@FM
DataFields := "START_TIME"      :@VM:SQL_Format(Rec(REACT_UTIL_START_TIME$),                       "TIME"):@FM
DataFields := "END_DATE"        :@VM:SQL_Format(Rec(REACT_UTIL_END_DATE$),                         "DATE"):@FM
DataFields := "END_TIME"        :@VM:SQL_Format(Rec(REACT_UTIL_END_TIME$),                         "TIME"):@FM
DataFields := "MODE_START_USER" :@VM:SQL_Format(Rec(REACT_UTIL_MODE_START_USER$),                  "STR"):@FM
DataFields := "MODE_FINISH_USER":@VM:SQL_Format(Rec(REACT_UTIL_MODE_FINISH_USER$),                 "STR"):@FM
DataFields := "WO"              :@VM:SQL_Format(Rec(REACT_UTIL_WO$),                               "INT"):@FM
DataFields := "CUST_NO"         :@VM:SQL_Format(Rec(REACT_UTIL_CUST_NO$),                          "STR"):@FM
DataFields := "REACTOR_LOG_ID"  :@VM:SQL_Format(Rec(REACT_UTIL_REACTOR_LOG_ID$),                   "INT"):@FM
DataFields := "NOTES"           :@VM:SQL_Format(Rec(REACT_UTIL_NOTES$),                            "STR"):@FM

// Symbolics
DataFields := "END_DTM"    :@VM:SQL_Format({END_DTM},     "DATETIME"):@FM
DataFields := "HRS_IN_MODE":@VM:SQL_Format({HRS_IN_MODE}, "DEC", 2):@FM
DataFields := "START_DTM"  :@VM:SQL_Format({START_DTM},   "DATETIME")

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

Return Ans
