Compile function Copy_GAN_THEO_CYCLE_TIME_RECORD_TO_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given GAN_THEO_CYCLE_TIME record to the MSSQL database.
	
	History
	-------
	12/14/2020    JRO   Original Programmer
\*****************************************************************************/

$insert GAN_THEO_CYCLE_TIME_EQUATES

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

// Parse record into a dimensioned array for speed
Dim Rec(5)
MatParse Record into Rec

RowsToExport = ''
StageCount = DCOUNT(Record<1>, @VM)

for StageKey = 1 to StageCount
	KeyID = Key : '*' : Record<GAN_THEO_CYCLE_TIME_STAGE$, StageKey>
	Keys = "ID":@VM:SQL_Format(KeyID, "STR")
	
	DataFields = ''
	DataFields := "PART_NO"					:@VM:SQL_Format(Key,                     "STR"):@FM
	DataFields := "STAGE"					:@VM:SQL_Format(Record<GAN_THEO_CYCLE_TIME_STAGE$,StageKey>,                    "STR"):@FM
	DataFields := "RECIPE_TIME"				:@VM:SQL_Format(Record<GAN_THEO_CYCLE_TIME_RECIPE_TIME$,StageKey>,                    "STR"):@FM
	DataFields := "OPERATOR_TOUCH_TIME"     :@VM:SQL_Format(Record<GAN_THEO_CYCLE_TIME_OPERATOR_TOUCH_TIME$,StageKey>,                    "STR"):@FM
	DataFields := "RUNS_PER_WEEK"			:@VM:SQL_Format(Record<GAN_THEO_CYCLE_TIME_RUNS_PER_WEEK$>,					   "STR")
		
	Ans = SQL_Write(Connection, "GAN_THEO_CYCLE_TIME", Keys, DataFields)
	
Next StageKey
Return Ans
