Compile function Copy_EPI_SUSCEPTOR_Record_To_SQL(Connection, Key, Record)

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

$insert EPI_SUSCEPTOR_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "CONFIG_DESC"    :@VM:SQL_Format(Rec(EPI_SUSCEPTOR_CONFIG_DESC$),     "STR"):@FM
DataFields := "TEST_WFRS_RUN"  :@VM:SQL_Format(Rec(EPI_SUSCEPTOR_TEST_WFRS_RUN$),   "DEC", "2"):@FM
DataFields := "PROVEIN_WFRS_WO":@VM:SQL_Format(Rec(EPI_SUSCEPTOR_PROVEIN_WFRS_WO$), "INT")

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

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

// EPI_SUSCEPTOR_POCKET_DETAIL
If Ans EQ "" AND Rec(EPI_SUSCEPTOR_POCKET_NO$) NE "" then
    
    // List of data fields and their values
    MvFields  = "POCKET_NO"  :@FM:SQL_Format(Rec(EPI_SUSCEPTOR_POCKET_NO$),   "INT"):@RM
    MvFields := "POCKET_ZONE":@FM:SQL_Format(Rec(EPI_SUSCEPTOR_POCKET_ZONE$), "INT"):@RM
    MvFields := "POCKET_TYPE":@FM:SQL_Format(Rec(EPI_SUSCEPTOR_POCKET_TYPE$), "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "EPI_SUSCEPTOR_POCKET_DETAIL", Keys, MvFields);
    
end

Return Ans
