Compile function Copy_ANNUAL_CONTRACTS_Record_To_SQL(Connection, Key, Record)

/*****************************************************************************\
	Copies the given ANNUAL_CONTRACTS record to the MSSQL database.
	
	History
	-------
	07/02/2010    KRF   Original Programmer
	04/21/2012    KRF   Dropped per David's Request, SQL_MFS Removed so this
	                    won't be called
\*****************************************************************************/

Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""

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

// List of data fields and their values
DataFields  = "CUST_NO"    :@VM:SQL_Format(Rec(1),  "INT"):@FM
DataFields := "ENTRY_ID"   :@VM:SQL_Format(Rec(2),  "STR"):@FM
DataFields := "ENTRY_DATE" :@VM:SQL_Format(Rec(3),  "DATE"):@FM
DataFields := "PO"         :@VM:SQL_Format(Rec(4),  "STR"):@FM
DataFields := "STATUS"     :@VM:SQL_Format(Rec(5),  "STR"):@FM
DataFields := "CLOSE_DATE" :@VM:SQL_Format(Rec(6),  "DATE"):@FM
DataFields := "NAME_NO"    :@VM:SQL_Format(Rec(7),  "INT"):@FM
DataFields := "FROM_DATE"  :@VM:SQL_Format(Rec(8),  "DATE"):@FM
DataFields := "THRU_DATE"  :@VM:SQL_Format(Rec(9),  "DATE"):@FM
DataFields := "WSIZE"      :@VM:SQL_Format(Rec(10), "STR"):@FM
DataFields := "NOTES"      :@VM:SQL_Format(Rec(13), "STR", 1):@FM
DataFields := "QUOTE_NUM"  :@VM:SQL_Format(Rec(21), "INT"):@FM
DataFields := "MIN_BALANCE":@VM:SQL_Format(Rec(22), "DEC", "2"):@FM
DataFields := "CUST_SPEC"  :@VM:SQL_Format(Rec(26), "STR"):@FM
DataFields := "PO_LINE"    :@VM:SQL_Format(Rec(34), "STR"):@FM
DataFields := "PO_REL"     :@VM:SQL_Format(Rec(35), "STR")

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

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

// ANNUAL_CONTRACTS_DESCRIPTION
If Ans EQ "" AND Rec(11) NE "" then
    
    // List of data fields and their values
    MvFields  = "DESCRIPTION":@FM:SQL_Format(Rec(11), "STR"):@RM
    MvFields := "CONTRACT_AMOUNT":@FM:SQL_Format(Rec(12), "DEC", "2"):@RM
    MvFields := "CONT_EFF_DT":@FM:SQL_Format(Rec(30), "DATE"):@RM
    MvFields := "CONT_END_DT":@FM:SQL_Format(Rec(31), "DATE"):@RM
    MvFields := "CONT_QTY":@FM:SQL_Format(Rec(32), "INT"):@RM
    MvFields := "CONT_PRICE":@FM:SQL_Format(Rec(33), "DEC", 2)
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_DESCRIPTION", Keys, MvFields);
    
end


// ANNUAL_CONTRACTS_QUOTES
If Ans EQ "" AND Rec(28) NE "" then
    
    // List of data fields and their values
    MvFields  = "QUOTE_NO":@FM:SQL_Format(Rec(28), "STR"):@RM
    MvFields := "PART_NO":@FM:SQL_Format(Rec(25), "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_QUOTES", Keys, MvFields);
    
end


// ANNUAL_CONTRACTS_ORDERS
If Ans EQ "" AND Rec(24) NE "" then
    
    // List of data fields and their values
    MvFields  = "ORDER_NO":@FM:SQL_Format(Rec(24), "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_ORDERS", Keys, MvFields);
    
end


// ANNUAL_CONTRACTS_LAYER_SET
If Ans EQ "" AND Rec(29) NE "" then
    
    // List of data fields and their values
    MvFields  = "LAYER_SET":@FM:SQL_Format(Rec(29), "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_LAYER_SET", Keys, MvFields);
    
end


// ANNUAL_CONTRACTS_PS_NO
If Ans EQ "" AND Rec(27) NE "" then
    
    // List of data fields and their values
    MvFields  = "PS_NO":@FM:SQL_Format(Rec(27), "STR")
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_PS_NO", Keys, MvFields);
    
end

// ANNUAL_CONTRACTS_RELEASE
If Ans EQ "" AND Rec(14) NE "" then
    
    // List of data fields and their values
    MvFields  = "REL_NO":@FM:SQL_Format(Rec(14), "STR"):@RM
    MvFields := "REL_PO":@FM:SQL_Format(Rec(15), "STR"):@RM
    MvFields := "REL_DATE":@FM:SQL_Format(Rec(16), "DATE"):@RM
    MvFields := "REL_WO":@FM:SQL_Format(Rec(17), "STR"):@RM
    MvFields := "REL_SETUP_CHARGE":@FM:SQL_Format(Rec(18), "DEC", 2):@RM
    MvFields := "REL_QUANTITY":@FM:SQL_Format(Rec(19), "INT"):@RM
    MvFields := "REL_PRICE":@FM:SQL_Format(Rec(20), "DEC", 2)
    
    // Write the data to the SQL database
    Ans = SQL_Write_MV(Connection, "ANNUAL_CONTRACTS_RELEASE", Keys, MvFields);
    
end

Return Ans
