Compile function Copy_VISION_LOG_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given VISION_LOG record to the MSSQL database.
	
	History
	-------
	08/06/2010    KRF   Original Programmer
	04/21/2012    KRF   Dropped per David's Request, SQL_MFS Removed so this
	                    won't be called
\*****************************************************************************/

$insert VISION_LOG_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 = "LOG_NO":@VM:SQL_Format(Key, "INT")

// List of data fields and their values
DataFields  = "TIMESTAMP"   :@VM:SQL_Format(Rec(VISION_LOG_TIMESTAMP$),    "DATETIME"):@FM
DataFields := "LOG_DESC"    :@VM:SQL_Format(Rec(VISION_LOG_LOG_DESC$),     "STR"):@FM
DataFields := "VISION_ORDER":@VM:SQL_Format(Rec(VISION_LOG_VISION_ORDER$), "STR"):@FM
DataFields := "VISION_LINE" :@VM:SQL_Format(Rec(VISION_LOG_VISION_LINE$),  "STR"):@FM
DataFields := "ORDER_NO"    :@VM:SQL_Format(Rec(VISION_LOG_ORDER_NO$),     "STR"):@FM
DataFields := "ITEM_NO"     :@VM:SQL_Format(Rec(VISION_LOG_ITEM_NO$),      "INT")

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

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

// VISION_LOG_DETAIL
If Ans EQ "" AND Rec(VISION_LOG_FIELD_NAME$) NE "" then
    
    // List of data fields and their values
    MvFields  = "FIELD_NAME"  :@FM:SQL_Format(Rec(VISION_LOG_FIELD_NAME$),   "STR"):@RM
    MvFields := "VISION_VALUE":@FM:SQL_Format(Rec(VISION_LOG_VISION_VALUE$), "STR"):@RM
    MvFields := "OI_VALUE"    :@FM:SQL_Format(Rec(VISION_LOG_OI_VALUE$),     "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "VISION_LOG_DETAIL", Keys, MvFields);
    
end

Return Ans
