Compile function Copy_LOT_Record_To_SQL(Connection, Key, Record)

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

$insert LOT_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "TYPE"                      :@VM:SQL_Format(Rec(LOT_TYPE$),                     "STR"):@FM
DataFields := "PROD_ID"                   :@VM:SQL_Format(Rec(LOT_PROD_ID$),                  "STR"):@FM
DataFields := "ORIG_WAFER_QTY"            :@VM:SQL_Format(Rec(LOT_ORIG_WAFER_QTY$),           "INT"):@FM
DataFields := "WAFER_QTY"                 :@VM:SQL_Format(Rec(LOT_WAFER_QTY$),                "INT"):@FM
DataFields := "VENDOR_PART_NO"            :@VM:SQL_Format(Rec(LOT_VENDOR_PART_NO$),           "STR"):@FM
DataFields := "VENDOR_LOT_NO"             :@VM:SQL_Format(Rec(LOT_VENDOR_LOT_NO$),            "STR"):@FM
DataFields := "VENDOR_CODE"               :@VM:SQL_Format(Rec(LOT_VENDOR_CODE$),              "STR"):@FM
DataFields := "[OPEN]"                    :@VM:SQL_Format(Rec(LOT_OPEN$),                     "BIT"):@FM
DataFields := "HOLD"                      :@VM:SQL_Format(Rec(LOT_HOLD$),                     "BIT"):@FM
DataFields := "HOT"                       :@VM:SQL_Format(Rec(LOT_HOT$),                      "BIT"):@FM
DataFields := "LEGACY_LOT_ID"             :@VM:SQL_Format(Rec(LOT_LEGACY_LOT_ID$),            "STR"):@FM
DataFields := "MOST_RECENT_LOT_EVENT_ID"  :@VM:SQL_Format(Rec(LOT_MOST_RECENT_LOT_EVENT_ID$), "STR"):@FM
DataFields := "LEGACY_LOT_TYPE"           :@VM:SQL_Format(Rec(LOT_LEGACY_LOT_TYPE$),          "STR"):@FM
DataFields := "WO_LOG_ID"                 :@VM:SQL_Format(Rec(LOT_WO_LOG_ID$),                "INT"):@FM
DataFields := "PROD_SPEC_ID"              :@VM:SQL_Format(Rec(LOT_PROD_SPEC_ID$),             "INT"):@FM
DataFields := "EPI_PART_NO"               :@VM:SQL_Format(Rec(LOT_EPI_PART_NO$),              "STR"):@FM
DataFields := "PROD_VER_NO"               :@VM:SQL_Format(Rec(LOT_PROD_VER_NO$),              "STR")

// Symbolics

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

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

Return Ans

