Compile function Copy_SCHED_DET_NG_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given SCHED_DET_NG record to the MSSQL database.
	
	History
	-------
	01/17/2023    DJS   Original Programmer
\*****************************************************************************/

$insert SCHED_DET_NG_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

// Parse record into a dimensioned array for speed
! Caution! Dim size must me large enough for all physical columns.
Dim Rec(17)
MatParse Record into Rec
					    
// List of key names and their values
Keys = "EVENT_ID":@VM:SQL_Format(Key, "STR")

// List of data fields and their values
DataFields  = "REACT_NO"         :@VM:SQL_Format(Rec(SCHED_DET_NG.REACT_NO$),       "INT"):@FM
DataFields := "WO_NO"            :@VM:SQL_Format(Rec(SCHED_DET_NG.WO_NO$),          "INT"):@FM
DataFields := "START_DTM"        :@VM:SQL_Format(Rec(SCHED_DET_NG.START_DTM$),      "DATETIME"):@FM
DataFields := "STOP_DTM"         :@VM:SQL_Format(Rec(SCHED_DET_NG.STOP_DTM$),       "DATETIME"):@FM
DataFields := "BLOCKOUT"         :@VM:SQL_Format(Rec(SCHED_DET_NG.BLOCK_OUT$),      "BIT"):@FM
DataFields := "BLOCK_OUT_TYPE"   :@VM:SQL_Format(Rec(SCHED_DET_NG.BLOCK_OUT_TYPE$), "STR"):@FM
DataFields := "EVENT_COMP"       :@VM:SQL_Format(Rec(SCHED_DET_NG.EVENT_COMP$),     "BIT")

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

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

Return Ans
