Compile function Copy_LOT_OPERATION_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given LOT_OPERATION record to the MSSQL database.
	
	History
	-------
	06/19/2025    DJS   Original Programmer
\*****************************************************************************/

$insert LOT_OPERATION_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "LOT_ID"                  :@VM:SQL_Format(Rec(LOT_OPERATION_LOT_ID$),                 "STR"):@FM
DataFields := "OPERATION_ID"            :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATION_ID$),           "STR"):@FM
DataFields := "DATETIME_IN"             :@VM:SQL_Format(Rec(LOT_OPERATION_DATETIME_IN$),            "DATETIME"):@FM
DataFields := "DATETIME_OUT"            :@VM:SQL_Format(Rec(LOT_OPERATION_DATETIME_OUT$),           "DATETIME"):@FM
DataFields := "EQUIPMENT_ID"            :@VM:SQL_Format(Rec(LOT_OPERATION_EQUIPMENT_ID$),           "STR"):@FM
DataFields := "WAFER_IN_QTY"            :@VM:SQL_Format(Rec(LOT_OPERATION_WAFER_IN_QTY$),           "INT"):@FM
DataFields := "WAFER_OUT_QTY"           :@VM:SQL_Format(Rec(LOT_OPERATION_WAFER_OUT_QTY$),          "INT"):@FM
DataFields := "OPERATOR_IN_ID"          :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATOR_IN_ID$),         "STR"):@FM
DataFields := "OPERATOR_OUT_ID"         :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATOR_OUT_ID$),        "STR"):@FM
DataFields := "OPERATION_SEQUENCE"      :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATION_SEQUENCE$),     "INT"):@FM
DataFields := "REWORK"                  :@VM:SQL_Format(Rec(LOT_OPERATION_REWORK$),                 "BIT"):@FM
DataFields := "DATETIME_START"          :@VM:SQL_Format(Rec(LOT_OPERATION_DATETIME_START$),         "DATETIME"):@FM
DataFields := "DATETIME_STOP"           :@VM:SQL_Format(Rec(LOT_OPERATION_DATETIME_STOP$),          "DATETIME"):@FM
DataFields := "CLEAN_ID"                :@VM:SQL_Format(Rec(LOT_OPERATION_CLEAN_ID$),               "STR"):@FM
DataFields := "PACKAGING_ID"            :@VM:SQL_Format(Rec(LOT_OPERATION_PACKAGING_ID$),           "STR"):@FM
DataFields := "WAFER_COUNTER_ID"        :@VM:SQL_Format(Rec(LOT_OPERATION_WAFER_COUNTER_ID$),       "STR"):@FM
DataFields := "OPERATION_TYPE"          :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATION_TYPE$),         "STR"):@FM
DataFields := "OPERATION_CLASS"         :@VM:SQL_Format(Rec(LOT_OPERATION_OPERATION_CLASS$),        "STR"):@FM
DataFields := "MET_TEST_TYPE_REQUIRED"  :@VM:SQL_Format(Rec(LOT_OPERATION_MET_TEST_TYPE_REQUIRED$), "BIT"):@FM
DataFields := "MET_TEST_REQUIRED"       :@VM:SQL_Format(Rec(LOT_OPERATION_MET_TEST_REQUIRED$),      "BIT"):@FM
DataFields := "PACKAGING_REQUIRED"      :@VM:SQL_Format(Rec(LOT_OPERATION_PACKAGING_REQUIRED$),     "BIT"):@FM
DataFields := "CLEAN_REQUIRED"          :@VM:SQL_Format(Rec(LOT_OPERATION_CLEAN_REQUIRED$),         "BIT"):@FM
DataFields := "WAFER_COUNTER_REQUIRED"  :@VM:SQL_Format(Rec(LOT_OPERATION_WAFER_COUNTER_REQUIRED$), "BIT")

// Symbolics

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

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

Return Ans
