Compile function Copy_SHIFT_CALENDAR_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given SHIFT_CALENDAR record to the MSSQL database.
	
	History
	-------
	10/02/2024    DJS   Original Programmer
\*****************************************************************************/

$insert SHIFT_CALENDAR_EQUATES

Declare function SQL_Write, SQL_Write_MV, 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  = "DAY"  :@VM:SQL_Format(Field(Key, "*", 1), "STR"):@FM
Keys := "FISCAL_YEAR":@VM:SQL_Format(Field(Key, "*", 2), "INT"):@FM
Keys := "SHIFT":@VM:SQL_Format(Field(Key, "*", 3), "STR")

// List of data fields and their values
DataFields  = "START_DTM"		:@VM:SQL_Format(Rec(SHIFT_CALENDAR.START_DTM$),     "DATETIME"):@FM
DataFields := "END_DTM"			:@VM:SQL_Format(Rec(SHIFT_CALENDAR.END_DTM$),       "DATETIME"):@FM
DataFields := "FISCAL_WEEK"     :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_WEEK$),          "STR"):@FM
DataFields := "FISCAL_MONTH"    :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_MONTH$),         "INT"):@FM
DataFields := "FISCAL_QUARTER"  :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_QUARTER$),       "STR")

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

Return Ans

