class= " lineNumbers " do
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
|
class= do
id= " codeSnippet767453 " class= " do ' velocidade acima de qry10002 com literals
Função pública GetDemand ()
Dbs não ofuscantes como a base de dados
Qdf não ofuscante como DAO.QueryDef
Rst não ofuscante como DAO.Recordset
sInsert não ofuscante como a corda, sSelect como a corda, sFrom como a corda, sWhere como a corda, sSQL como a corda
lRecordCount não ofuscante como por muito tempo: lRecordCount = 0
lCounter não ofuscante como por muito tempo
DoCmd.SetWarnings falso
DoCmd.RunSQL “SUPRESSÃO * do tblDemand”
'sInsert = “INSERÇÃO no tblDemand”
sSelect = “LOWES.T2398_IFM_FRC_VAL.T024_ITM_NBR SELETO, LOWES.T2398_IFM_FRC_VAL.T063_LCT_NBR, CASO QUANDO EXTREMIDADE SEN_END_WK_NBR-SEN_BGN_WK_NBR+1 52-SEN_BGN_WK_NBR+SEN_END_WK_NBR+1 OUTRA de SEN_BGN_WK_NBR<=SEN_END_WK_NBR ENTÃO COMO o "" que vende o "" das semanas,” & o _
“LOWES.T2355_SEN_PRL.WK1_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK2_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK3_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK4_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK5_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK6_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK7_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK8_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK9_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK10_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK11_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK12_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK13_BAS_IND_FCT COMO a soma do "" Q1 do "" do BIs,” & do _
“LOWES.T2355_SEN_PRL.WK14_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK15_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK16_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK17_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK18_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK19_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK20_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK21_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK22_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK23_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK24_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK25_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK26_BAS_IND_FCT COMO a soma do "" Q2 do "" do BIs,” & do _
“LOWES.T2355_SEN_PRL.WK27_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK28_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK29_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK30_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK31_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK32_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK33_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK34_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK35_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK36_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK37_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK38_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK39_BAS_IND_FCT COMO a soma do "" Q3 do "" do BIs,” & do _
“LOWES.T2355_SEN_PRL.WK40_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK41_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK42_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK43_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK44_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK45_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK46_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK47_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK48_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK49_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK50_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK51_BAS_IND_FCT+LOWES.T2355_SEN_PRL.WK52_BAS_IND_FCT COMO a soma do "" Q4 do """ do BIs
o sFrom = “(LOWES.T2354_ITM_LCT_PRL INTERNOS SE JUNTAM A LOWES.T2355_SEN_PRL EM LOWES.T2354_ITM_LCT_PRL.T2355_PRL_TAG_ID = LOWES.T2355_SEN_PRL.T2355_PRL_TAG_ID) DE INTERNO JUNTA-SE A LOWES.T2398_IFM_FRC_VAL SOBRE (LOWES.T2354_ITM_LCT_PRL.T063_LCT_NBR = LOWES.T2398_IFM_FRC_VAL.T063_LCT_NBR) E (LOWES.T2354_ITM_LCT_PRL.T024_ITM_NBR = LOWES.T2398_IFM_FRC_VAL.T024_ITM_NBR)”
sWhere = “ONDE (LOWES.T2398_IFM_FRC_VAL.T024_ITM_NBR = -1 E LOWES.T2398_IFM_FRC_VAL.T063_LCT_NBR = -1)”
Ajustar dbs = CurrentDb ()
Ajustar o rst = o dbs.OpenRecordset (“T024_ITM_NBR SELETO, T063_LCT_NBR de Demand_Check_C; ")
Se rst.EOF então
lRecordCount = 0
Mais
rst.MoveLast
lRecordCount = rst.RecordCount
Terminar se
rst.MoveFirst
Fazer quando não rst.EOF
lCounter = lCounter + 1
sWhere = sWhere & “OU (LOWES.T2398_IFM_FRC_VAL.T024_ITM_NBR =” & rst (“T024_ITM_NBR”) &” E LOWES.T2398_IFM_FRC_VAL.T063_LCT_NBR = “& rst (“T063_LCT_NBR”) & ") “
Se lCounter > 60 ou rst.AbsolutePosition = lRecordCount - 1 então
sSQL = sInsert & sSelect & sFrom & sWhere '& “COM UR”
Ajustar o qdf = o CurrentDb () .QueryDefs (o “qryPassThrough”)
qdf.SQL = sSQL
DoCmd.OpenQuery “qryDemand”
'sSQL de DoCmd.RunSQL
lCounter = 0
sWhere = “ONDE (LOWES.T2398_IFM_FRC_VAL.T024_ITM_NBR = -1 E LOWES.T2398_IFM_FRC_VAL.T063_LCT_NBR = -1)” '- 1 = manequim # para tratar o ø OU
Terminar se
rst.MoveNext
Laço
DoCmd.SetWarnings verdadeiro
rst. Fim
Função do fim
|