Compile function Copy_LOT_EVENT_Record_To_SQL(Connection, Key, Record)

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

$insert LOT_EVENT_EQUATES

Declare function SQL_Write, SQL_Write_MV, 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 = "LOT_EVENT_ID":@VM:SQL_Format(Key, "STR")

// List of data fields and their values
DataFields  = "LOT_ID"                 :@VM:SQL_Format(Rec(LOT_EVENT_LOT_ID$),                 "STR"):@FM
DataFields := "LOT_EVENT_TYPE"         :@VM:SQL_Format(Rec(LOT_EVENT_LOT_EVENT_TYPE$),         "STR"):@FM
DataFields := "EVENT_DATETIME"         :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_DATETIME$),         "DATETIME"):@FM
DataFields := "EVENT_NOTE"             :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_NOTE$),             "STR"):@FM
DataFields := "EQUIPMENT_ID"           :@VM:SQL_Format(Rec(LOT_EVENT_EQUIPMENT_ID$),           "STR"):@FM
DataFields := "EVENT_REDUCE_WAFER_QTY" :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_REDUCE_WAFER_QTY$), "INT"):@FM
DataFields := "EVENT_BONUS_WAFER_QTY"  :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_BONUS_WAFER_QTY$),  "INT"):@FM
DataFields := "EVENT_BEGIN_WAFER_QTY"  :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_BEGIN_WAFER_QTY$),  "INT"):@FM
DataFields := "EVENT_END_WAFER_QTY"    :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_END_WAFER_QTY$),    "INT"):@FM
DataFields := "EVENT_OPERATION_ID"     :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_OPERATION_ID$),     "STR"):@FM
DataFields := "EVENT_OPERATOR_ID"      :@VM:SQL_Format(Rec(LOT_EVENT_EVENT_OPERATOR_ID$),      "STR"):@FM
DataFields := "SEQUENCE"               :@VM:SQL_Format(Rec(LOT_EVENT_SEQUENCE$),               "INT")

// Symbolics

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

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

Return Ans
