203 lines
10 KiB
Plaintext
203 lines
10 KiB
Plaintext
Compile function Copy_NCR_Record_To_SQL(Connection, Key, Record)
|
|
|
|
/*****************************************************************************\
|
|
Copies the given NCR record to the MSSQL database.
|
|
|
|
History
|
|
-------
|
|
04/22/2010 KRF Original Programmer
|
|
07/01/2012 KRF Removed REJ_CNT_FIELD, REJ_CNT_VALUE, and REJ_CNT_ORIG
|
|
fields and added TOT_REJ symbolic.
|
|
03/15/2019 DJS Updated Dim Rec(76) to Dim Rec(82) to resolve SQL_ERROR.
|
|
\*****************************************************************************/
|
|
|
|
$insert NCR_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(76)
|
|
Dim Rec(82)
|
|
MatParse Record into Rec
|
|
|
|
// List of key names and their values
|
|
Keys = "SEQ":@VM:SQL_Format(Key, "INT")
|
|
|
|
// Conversions
|
|
NCR_Status = OConv(Rec(NCR_STATUS$), "[NCR_STATUS_CONV]")
|
|
NCR_LossBy = OConv(Rec(NCR_LOSS_BY$), "[NCR_LOSS_BY_CONV]")
|
|
|
|
// List of data fields and their values
|
|
DataFields = "ENTRY_ID" :@VM:SQL_Format(Rec(NCR_ENTRY_ID$), "STR"):@FM
|
|
DataFields := "ENTRY_DATE" :@VM:SQL_Format(Rec(NCR_ENTRY_DATE$), "DATE"):@FM
|
|
DataFields := "ENTRY_TIME" :@VM:SQL_Format(Rec(NCR_ENTRY_TIME$), "TIME"):@FM
|
|
DataFields := "DEPT" :@VM:SQL_Format(Rec(NCR_DEPT$), "STR"):@FM
|
|
DataFields := "SHIFT" :@VM:SQL_Format(Rec(NCR_SHIFT$), "STR"):@FM
|
|
DataFields := "STATUS" :@VM:SQL_Format(NCR_Status, "STR"):@FM
|
|
DataFields := "LOSS_COMMENTS" :@VM:SQL_Format(Rec(NCR_LOSS_COMMENTS$), "STR", 1):@FM
|
|
DataFields := "AC_COMMENTS" :@VM:SQL_Format(Rec(NCR_AC_COMMENTS$), "STR", 1):@FM
|
|
DataFields := "DEPT_RESP" :@VM:SQL_Format(Rec(NCR_DEPT_RESP$), "STR"):@FM
|
|
DataFields := "DEPT_MGR_SIG" :@VM:SQL_Format(Rec(NCR_DEPT_MGR_SIG$), "STR"):@FM
|
|
DataFields := "AUTH_SHIP_SIG" :@VM:SQL_Format(Rec(NCR_AUTH_SHIP_SIG$), "STR"):@FM
|
|
DataFields := "AUTH_REWORK_SIG" :@VM:SQL_Format(Rec(NCR_AUTH_REWORK_SIG$), "STR"):@FM
|
|
DataFields := "AUTH_REJ_SIG" :@VM:SQL_Format(Rec(NCR_AUTH_REJ_SIG$), "STR"):@FM
|
|
DataFields := "AUTH_DEV_SIG" :@VM:SQL_Format(Rec(NCR_AUTH_DEV_SIG$), "STR"):@FM
|
|
DataFields := "VP_SIG" :@VM:SQL_Format(Rec(NCR_VP_SIG$), "STR"):@FM
|
|
* DataFields := "REJ_CNT_FIELD" :@VM:SQL_Format(Rec(NCR_REJ_CNT_FIELD$), "STR"):@FM
|
|
* DataFields := "REJ_CNT_VALUE" :@VM:SQL_Format(Rec(NCR_REJ_CNT_VALUE$), "INT"):@FM
|
|
DataFields := "GENERAL_COMMENTS" :@VM:SQL_Format(Rec(NCR_GENERAL_COMMENTS$), "STR", 1):@FM
|
|
DataFields := "VERIFIED_COMMENTS":@VM:SQL_Format(Rec(NCR_VERIFIED_COMMENTS$), "STR", 1):@FM
|
|
DataFields := "LOSS_CODE_ORIG" :@VM:SQL_Format(Rec(NCR_LOSS_CODE_ORIG$), "STR"):@FM
|
|
DataFields := "AC_CODE_ORIG" :@VM:SQL_Format(Rec(NCR_AC_CODE_ORIG$), "STR"):@FM
|
|
* DataFields := "REJ_CNT_ORIG" :@VM:SQL_Format(Rec(NCR_REJ_CNT_ORIG$), "INT"):@FM
|
|
DataFields := "DEPT_MGR_COMMENTS":@VM:SQL_Format(Rec(NCR_DEPT_MGR_COMMENTS$), "STR", 1):@FM
|
|
DataFields := "CONTAIN_ACTIONS" :@VM:SQL_Format(Rec(NCR_CONTAIN_ACTIONS$), "STR", 1):@FM
|
|
DataFields := "TTHICK_AVG" :@VM:SQL_Format(Rec(NCR_TTHICK_AVG$), "DEC", "2"):@FM
|
|
DataFields := "TTHICK_STDEV" :@VM:SQL_Format(Rec(NCR_TTHICK_STDEV$), "DEC", "3"):@FM
|
|
DataFields := "TTHICK_MAX" :@VM:SQL_Format(Rec(NCR_TTHICK_MAX$), "DEC", "2"):@FM
|
|
DataFields := "TTHICK_MIN" :@VM:SQL_Format(Rec(NCR_TTHICK_MIN$), "DEC", "2"):@FM
|
|
DataFields := "TTHICK_UNIF" :@VM:SQL_Format(Rec(NCR_TTHICK_UNIF$), "DEC", "2"):@FM
|
|
DataFields := "TRES_AVG" :@VM:SQL_Format(Rec(NCR_TRES_AVG$), "DEC", "3"):@FM
|
|
DataFields := "TRES_STDEV" :@VM:SQL_Format(Rec(NCR_TRES_STDEV$), "DEC", "3"):@FM
|
|
DataFields := "TRES_MAX" :@VM:SQL_Format(Rec(NCR_TRES_MAX$), "DEC", "3"):@FM
|
|
DataFields := "TRES_MIN" :@VM:SQL_Format(Rec(NCR_TRES_MIN$), "DEC", "3"):@FM
|
|
DataFields := "TRES_UNIF" :@VM:SQL_Format(Rec(NCR_TRES_UNIF$), "DEC", "2"):@FM
|
|
DataFields := "LPD" :@VM:SQL_Format(Rec(NCR_LPD$), "INT"):@FM
|
|
DataFields := "PITS" :@VM:SQL_Format(Rec(NCR_PITS$), "INT"):@FM
|
|
DataFields := "MOUNDS" :@VM:SQL_Format(Rec(NCR_MOUNDS$), "INT"):@FM
|
|
DataFields := "BL_DEFECTS" :@VM:SQL_Format(Rec(NCR_BL_DEFECTS$), "INT"):@FM
|
|
DataFields := "STACK_FAULTS" :@VM:SQL_Format(Rec(NCR_STACK_FAULTS$), "INT"):@FM
|
|
DataFields := "SPIKES" :@VM:SQL_Format(Rec(NCR_SPIKES$), "INT"):@FM
|
|
DataFields := "SPOTS" :@VM:SQL_Format(Rec(NCR_SPOTS$), "INT"):@FM
|
|
DataFields := "SPOT_FOV" :@VM:SQL_Format(Rec(NCR_SPOT_FOV$), "INT"):@FM
|
|
DataFields := "SCRATCHES" :@VM:SQL_Format(Rec(NCR_SCRATCHES$), "INT"):@FM
|
|
DataFields := "SCRATCH_LEN" :@VM:SQL_Format(Rec(NCR_SCRATCH_LEN$), "INT"):@FM
|
|
DataFields := "SURF_DEFECTS" :@VM:SQL_Format(Rec(NCR_SURF_DEFECTS$), "INT"):@FM
|
|
DataFields := "SURF_HAZE" :@VM:SQL_Format(Rec(NCR_SURF_HAZE$), "DEC", "2"):@FM
|
|
DataFields := "UNIT_TYPE" :@VM:SQL_Format(Rec(NCR_UNIT_TYPE$), "STR"):@FM
|
|
DataFields := "LOSS_BY" :@VM:SQL_Format(NCR_LossBy, "STR"):@FM
|
|
DataFields := "LOSS_STAGE" :@VM:SQL_Format(Rec(NCR_LOSS_STAGE$), "STR"):@FM
|
|
DataFields := "AC_CODE" :@VM:SQL_Format(Rec(NCR_AC_CODE$), "STR"):@FM
|
|
DataFields := "LOSS_CODE" :@VM:SQL_Format(Rec(NCR_LOSS_CODE$), "STR"):@FM
|
|
DataFields := "WO_NO" :@VM:SQL_Format(Rec(NCR_WO_NO$), "STR"):@FM
|
|
DataFields := "WO_STEP" :@VM:SQL_Format(Rec(NCR_WO_STEP$), "INT"):@FM
|
|
DataFields := "WO_MAT_CASS_NO" :@VM:SQL_Format(Rec(NCR_WO_MAT_CASS_NO$), "INT"):@FM
|
|
DataFields := "REC_VER" :@VM:SQL_Format(Rec(NCR_REC_VER$), "INT"):@FM
|
|
DataFields := "LAST_QTY_DTM" :@VM:SQL_Format(Rec(NCR_LAST_QTY_DTM$), "DATETIME"):@FM
|
|
|
|
// Symblics
|
|
DataFields := "TOT_REJ" :@VM:SQL_Format({TOT_REJ}, "INT"):@FM
|
|
DataFields := "AC_DESC" :@VM:SQL_Format({AC_DESC}, "STR"):@FM
|
|
DataFields := "CUST_ID" :@VM:SQL_Format({CUST_ID}, "INT"):@FM
|
|
DataFields := "CUST_NAME" :@VM:SQL_Format({CUST_NAME}[1,50], "STR"):@FM
|
|
DataFields := "LOSS_DESC" :@VM:SQL_Format({LOSS_DESC}, "STR"):@FM
|
|
DataFields := "PROD_SPEC_NO":@VM:SQL_Format({PROD_SPEC_NO}, "STR"):@FM
|
|
DataFields := "REACTOR_TYPE":@VM:SQL_Format({REACTOR_TYPE}, "STR"):@FM
|
|
DataFields := "SAP_BATCH_NO":@VM:SQL_Format({SAP_BATCH_NO}, "STR"):@FM
|
|
DataFields := "CASS_ID_SAP" :@VM:SQL_Format({CASS_ID_SAP}, "STR"):@FM
|
|
DataFields := "ENTRY_DTM" :@VM:SQL_Format({ENTRY_DTM}, "DATETIME")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write(Connection, "NCR", Keys, DataFields)
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
// Multi-valued Fields
|
|
|
|
// RDS IDs
|
|
If Ans EQ "" AND (Rec(NCR_RDS_ID$) NE "" OR Rec(NCR_REACTOR$) NE "") then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "RDS_ID" :@FM:SQL_Format(Rec(NCR_RDS_ID$), "INT"):@RM
|
|
MvFields := "REACTOR":@FM:SQL_Format(Rec(NCR_REACTOR$), "INT")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_RDS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// Thick Reads
|
|
If Ans EQ "" AND Rec(NCR_THICK_READ$) NE "" then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "THICK_READ":@FM:SQL_Format(Rec(NCR_THICK_READ$), "DEC", 2)
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_THICK_READS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// RHO Reads
|
|
If Ans EQ "" AND Rec(NCR_SHEETRHO_READ$) NE "" then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "SHEETRHO_READ":@FM:SQL_Format(Rec(NCR_SHEETRHO_READ$), "DEC", 2)
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_RHO_READS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// Trej Counts
|
|
If Ans EQ "" AND Rec(NCR_TREJ_CNT$) NE "" then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "TREJ_CNT":@FM:SQL_Format(Rec(NCR_TREJ_CNT$), "INT")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_TREJ_CNTS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// Combines the SLOT_REJECT, CASS_NO, and CASSETTE_SLOT edittables
|
|
If Ans EQ "" AND (Rec(57) NE "" OR Rec(58) NE "" OR Rec(59) NE "" OR Rec(60) NE "" OR Rec(61) NE "" OR Rec(65) NE "" OR Rec(66) NE "" OR Rec(67) NE "" OR Rec(68) NE "" OR Rec(69) NE "" OR Rec(70) NE "" OR Rec(71) NE "" OR Rec(72) NE "" OR Rec(73) NE "") then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "SLOT_NO":@FM:SQL_Format(Rec(57), "INT"):@RM
|
|
MvFields := "CASS_NO":@FM:SQL_Format(Rec(58), "INT"):@RM
|
|
MvFields := "POCKET_NO":@FM:SQL_Format(Rec(59), "INT"):@RM
|
|
MvFields := "OUT_CASS_NO":@FM:SQL_Format(Rec(60), "INT"):@RM
|
|
MvFields := "OUT_SLOT_NO":@FM:SQL_Format(Rec(61), "INT"):@RM
|
|
MvFields := "WM_RDS_NO":@FM:SQL_Format(Rec(65), "INT"):@RM
|
|
MvFields := "ZONE":@FM:SQL_Format(Rec(66), "STR"):@RM
|
|
MvFields := "REJ_WAFER_ID":@FM:SQL_Format(Rec(67), "STR"):@RM
|
|
MvFields := "PREV_NCR_NO":@FM:SQL_Format(Rec(68), "STR"):@RM
|
|
MvFields := "REJ_MET_NO":@FM:SQL_Format(Rec(69), "STR"):@RM
|
|
MvFields := "MU_WO_NO":@FM:SQL_Format(Rec(70), "STR"):@RM
|
|
MvFields := "MU_STEP":@FM:SQL_Format(Rec(71), "STR"):@RM
|
|
MvFields := "MU_CASS":@FM:SQL_Format(Rec(72), "STR"):@RM
|
|
MvFields := "MU_SLOT":@FM:SQL_Format(Rec(73), "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_SLOTS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// NCR_LOT_NUM
|
|
LotNum = {LOT_NUM}
|
|
If Ans EQ "" AND LotNum NE "" then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "LOT_NUM":@FM:SQL_Format(LotNum, "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_LOT_NUM", Keys, MvFields);
|
|
|
|
end
|
|
|
|
// NCR_PART_NUM
|
|
PartNo = {PART_NO}
|
|
If Ans EQ "" AND PartNo NE "" then
|
|
|
|
// List of data fields and their values
|
|
MvFields = "PART_NO":@FM:SQL_Format(PartNo, "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "NCR_PART_NUM", Keys, MvFields);
|
|
|
|
end
|
|
|
|
Return Ans
|
|
|