Compile function Copy_PM_HIST_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given PM_HIST record to the MSSQL database.
	
	History
	-------
	11/30/2016    KRF   Original Programmer
\*****************************************************************************/

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

$insert PM_HIST_EQUATES

// Parse record into a dimensioned array for speed
Dim Rec(2)
MatParse Record into Rec
					    
// List of key names and their values
Keys = "PMS_ID":@VM:SQL_Format(Key, "INT")

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

// PM_HIST
If Ans EQ "" AND Rec(PM_HIST_PM_KEYS$) NE "" then
        
    // List of data fields and their values
    MvFields = "PM_KEYS":@FM:SQL_Format(Rec(PM_HIST_PM_KEYS$), "INT")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "PM_HIST", Keys, MvFields)
    
end

Return Ans
