Compile function Copy_OPERATION_Record_To_SQL(Connection, Key, Record)

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

$insert OPERATION_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "ACTIVE"                  :@VM:SQL_Format(Rec(OPERATION_ACTIVE$),                 "BIT"):@FM
DataFields := "CLASS_ID"                :@VM:SQL_Format(Rec(OPERATION_CLASS_ID$),               "STR"):@FM
DataFields := "OPERATION_DESCRIPTION"   :@VM:SQL_Format(Rec(OPERATION_OPERATION_DESCRIPTION$),  "STR"):@FM
DataFields := "TYPE"                    :@VM:SQL_Format(Rec(OPERATION_TYPE$),                   "STR"):@FM
DataFields := "REWORK"                  :@VM:SQL_Format(Rec(OPERATION_REWORK$),                 "BIT"):@FM
DataFields := "MET_TEST_TYPE_REQUIRED"  :@VM:SQL_Format(Rec(OPERATION_MET_TEST_TYPE_REQUIRED$), "BIT"):@FM
DataFields := "MET_TEST_REQUIRED"       :@VM:SQL_Format(Rec(OPERATION_MET_TEST_REQUIRED$),      "BIT"):@FM
DataFields := "PACKAGING_REQUIRED"      :@VM:SQL_Format(Rec(OPERATION_PACKAGING_REQUIRED$),     "BIT"):@FM
DataFields := "CLEAN_REQUIRED"          :@VM:SQL_Format(Rec(OPERATION_CLEAN_REQUIRED$),         "BIT"):@FM
DataFields := "WAFER_COUNTER_REQUIRED"  :@VM:SQL_Format(Rec(OPERATION_WAFER_COUNTER_REQUIRED$), "BIT")

// Symbolics

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

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

Return Ans
