AUTO RUNNING ^^
AUTO RUNNING
Public Sub DROP_RunnoFG()
Dim ssql As String
Dim Table As New Data.DataTable
Dim dtDATx As New DataTable
Dim DteTime As Date = ssCON.Exc_GETToday
Try
Dim SQL_DT As String = "SELECT * FROM TFG_MASTER WHERE CODEID = 'RU' " & _
" AND TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYY/MM/DD') <> TO_CHAR(UPDDTE ,'YYYY/MM/DD')"
dtDATx = ssCON.Exc_Reader(SQL_DT)
If dtDATx.Rows.Count > 0 Then
''DROP
ssql = "DROP SEQUENCE emp_TFG_RECORDSEQ_J03 "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG_PALLETKEY_J03 "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG__RCMANGENO_FG "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG_RECEIVING_SEQ "
Table.Rows.Add(ssql)
''CREATE RECORDSEQ
ssql = "Create sequence emp_TFG_RECORDSEQ_J03 " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''PALLET KEY
ssql = "Create sequence emp_TFG_PALLETKEY_J03 " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 9999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''FG = RC170715000154 = RC NO
ssql = "Create sequence emp_TFG__RCMANGENO_FG " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''SEQ
ssql = "Create sequence emp_TFG_RECEIVING_SEQ " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''UPD
ssql = "UPDATE TFG_MASTER SET " & _
" VALUE1 = TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYYMMDD') " & _
",SYSDTE = TO_DATE('" & Strings.Format(DteTime, formatDATE) & "', 'yyyy/MM/dd hh24:mi:ss') " & _
",UPDDTE = TO_DATE('" & Strings.Format(DteTime, formatDATE) & "', 'yyyy/MM/dd hh24:mi:ss') " & _
" WHERE CODEID = 'RU' AND TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYY/MM/DD') <> TO_CHAR(UPDDTE ,'YYYY/MM/DD')"
Table.Rows.Add(ssql)
End If
If SaveSP(Table, "DELRunnoFG", "DELRunnoFG") = True Then
Exit Sub
End If
Catch ex As Exception
Exit Sub
End Try
End Sub
-- นำไปใช้งาน ----AUTO RUNNING -------------------------------------
Public Function GET_TFG_RECORD_SEQ() As String
Dim ssqlRunning As String
Dim dtRunning As New DataTable
ssqlRunning = "select emp_TFG_RECORDSEQ_J03.nextval as genRunno from dual"
dtRunning = ssCON.Exc_Reader(ssqlRunning)
If dtRunning.Rows.Count > 0 Then
GET_TFG_RECORD_SEQ = dtRunning.Rows(0)("genRunno").ToString()
Exit Function
Else
GET_TFG_RECORD_SEQ = 0
Exit Function
End If
End Function
Public Sub DROP_RunnoFG()
Dim ssql As String
Dim Table As New Data.DataTable
Dim dtDATx As New DataTable
Dim DteTime As Date = ssCON.Exc_GETToday
Try
Dim SQL_DT As String = "SELECT * FROM TFG_MASTER WHERE CODEID = 'RU' " & _
" AND TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYY/MM/DD') <> TO_CHAR(UPDDTE ,'YYYY/MM/DD')"
dtDATx = ssCON.Exc_Reader(SQL_DT)
If dtDATx.Rows.Count > 0 Then
''DROP
ssql = "DROP SEQUENCE emp_TFG_RECORDSEQ_J03 "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG_PALLETKEY_J03 "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG__RCMANGENO_FG "
Table.Rows.Add(ssql)
ssql = "DROP SEQUENCE emp_TFG_RECEIVING_SEQ "
Table.Rows.Add(ssql)
''CREATE RECORDSEQ
ssql = "Create sequence emp_TFG_RECORDSEQ_J03 " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''PALLET KEY
ssql = "Create sequence emp_TFG_PALLETKEY_J03 " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 9999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''FG = RC170715000154 = RC NO
ssql = "Create sequence emp_TFG__RCMANGENO_FG " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''SEQ
ssql = "Create sequence emp_TFG_RECEIVING_SEQ " & _
" start with 1 " & _
" increment by 1 " & _
" minvalue 1 " & _
" maxvalue 99999 " & _
" cache 10 "
Table.Rows.Add(ssql)
''UPD
ssql = "UPDATE TFG_MASTER SET " & _
" VALUE1 = TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYYMMDD') " & _
",SYSDTE = TO_DATE('" & Strings.Format(DteTime, formatDATE) & "', 'yyyy/MM/dd hh24:mi:ss') " & _
",UPDDTE = TO_DATE('" & Strings.Format(DteTime, formatDATE) & "', 'yyyy/MM/dd hh24:mi:ss') " & _
" WHERE CODEID = 'RU' AND TO_CHAR(TO_DATE('" & Strings.Format(DteTime, formatDATEShort) & "', 'yyyyMMdd'),'YYYY/MM/DD') <> TO_CHAR(UPDDTE ,'YYYY/MM/DD')"
Table.Rows.Add(ssql)
End If
If SaveSP(Table, "DELRunnoFG", "DELRunnoFG") = True Then
Exit Sub
End If
Catch ex As Exception
Exit Sub
End Try
End Sub
-- นำไปใช้งาน ----AUTO RUNNING -------------------------------------
Public Function GET_TFG_RECORD_SEQ() As String
Dim ssqlRunning As String
Dim dtRunning As New DataTable
ssqlRunning = "select emp_TFG_RECORDSEQ_J03.nextval as genRunno from dual"
dtRunning = ssCON.Exc_Reader(ssqlRunning)
If dtRunning.Rows.Count > 0 Then
GET_TFG_RECORD_SEQ = dtRunning.Rows(0)("genRunno").ToString()
Exit Function
Else
GET_TFG_RECORD_SEQ = 0
Exit Function
End If
End Function
ไม่มีความคิดเห็น