Compile function Copy_TOOL_ESC_Record_To_SQL(Connection, Key, Record)

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

$insert TOOL_ESC_EQUATES

Declare function SQL_Write, SQL_Format
Ans = ""

// Parse record into a dimensioned array for speed
Dim Rec(6)
MatParse Record into Rec
					    
// List of key names and their values
Keys  = "TOOL_ID"  :@VM:SQL_Format(Field(Key, "*", 1), "STR"):@FM
Keys := "START_DTM":@VM:SQL_Format(Field(Key, "*", 2), "DATETIME")

// List of data fields and their values
DataFields  = "START_USER"  :@VM:SQL_Format(Rec(TOOL_ESC_START_USER$),   "STR"):@FM
DataFields := "START_REASON":@VM:SQL_Format(Rec(TOOL_ESC_START_REASON$), "STR"):@FM
DataFields := "STOP_DTM"    :@VM:SQL_Format(Rec(TOOL_ESC_STOP_DTM$),     "DATETIME"):@FM
DataFields := "STOP_USER"   :@VM:SQL_Format(Rec(TOOL_ESC_STOP_USER$),    "STR"):@FM
DataFields := "STOP_REASON" :@VM:SQL_Format(Rec(TOOL_ESC_STOP_REASON$),  "STR")

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

Return Ans
