これは私にとってまったく新しいことです。ご容赦ください。
データを収集して Web サーバー上の mySQL テーブルに送信するフォームが Web サイトにある状況があります。その情報は、WebサーバーからLinuxボックスのmySQLテーブルに送信されます。Linuxボックスの何らかのインポートスクリプトを介して信じています。
先週、Linux サーバーがハングアップし、インポート スクリプトが機能しなくなりました。再起動する必要がある import.txt ファイルがありますが (信じられます)、その方法がわかりません。
Web で調査しましたが、.sh ファイルに関する情報しか表示されません。
ありがとう!
それが役立つ場合に実行する必要があるのは次のとおりです。
Public Sub ImportPubOrders()
Dim rsCopy1 As Recordset, rsCopy2 As Recordset, rsCopy3 As Recordset
Dim strSQL As String, strCriteria As String, strODBCdate As String
Dim lngFound As Long
On Error GoTo ErrorHandler
Set wrkODBC = CreateWorkspace("ODBCWorkSpace", "pubadmin", "Abo1prA5", dbUseODBC)
Set MySQLConn = wrkODBC.OpenConnection("ODBC;DSN=publications;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=publications;SERVER=10.116.11.2;UID=pubadmin;PASSWORD=Abo1prA5;PORT=3306;OPTION=3;STMT=;")
MySQLConn.QueryTimeout = 180
strODBCdate = Format(DateAdd("d", -1, Date), "yyyy-mm-dd")
'strODBCdate = "2009-03-11"
'Copy records from More.net PRO to DBSRVR
Set OAwrkODBC = CreateWorkspace("ODBCWorkSpace", "sslAGOmySQL", "k4-4js94nd", dbUseODBC)
Set OAMySQLConn = OAwrkODBC.OpenConnection("ODBC;DSN=OA_generalPRO;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=www_ago_mo_gov_ssl_data;SERVER=db.kinetic.more.net;UID=sslAGOmySQL;PASSWORD=k4-4js94nd;PORT=3306;OPTION=3;STMT=;")
strSQL = "LOCK TABLE orders_contacts READ, orders_ids READ, orders_items READ, orders_order READ"
OAMySQLConn.Execute (strSQL)
'Check if there are orders to download
strCriteria = "DATE_FORMAT(orders_order.order_date, '%Y-%m-%d') = " & Chr(34) & strODBCdate & Chr(34)
strSQL = "SELECT form_id FROM orders_order WHERE " & strCriteria
OAMySQLConn.Execute (strSQL)
lngFound = OAMySQLConn.RecordsAffected
'Orders have been submitted and need to be downloaded
If lngFound >= 1 Then
strSQL = "SELECT form_id, contact_id, DATE_FORMAT(order_date, '%Y-%m-%d %T') AS order_date FROM orders_order WHERE " & strCriteria
Set rsCopy1 = OAMySQLConn.OpenRecordset(strSQL)
Do While Not rsCopy1.EOF
strSQL = "INSERT INTO orders_order (form_id, contact_id, order_date) " & _
"VALUES (" & rsCopy1!form_id & ", " & rsCopy1!contact_id & ", " & Chr(34) & rsCopy1!order_date & Chr(34) & ")"
MySQLConn.Execute (strSQL)
rsCopy1.MoveNext
Loop
rsCopy1.Close
strSQL = "SELECT item_id, orders_items.form_id, pub_name, quantity " & _
"FROM orders_items INNER JOIN orders_order ON orders_items.form_id = orders_order.form_id " & _
"WHERE " & strCriteria
Set rsCopy2 = OAMySQLConn.OpenRecordset(strSQL)
Do While Not rsCopy2.EOF
strSQL = "INSERT INTO orders_items (item_id, form_id, pub_name, quantity) " & _
"VALUES (" & rsCopy2!item_id & ", " & rsCopy2!form_id & ", " & Chr(34) & rsCopy2!pub_name & Chr(34) & ", " & rsCopy2!quantity & ")"
MySQLConn.Execute (strSQL)
rsCopy2.MoveNext
Loop
rsCopy2.Close
strSQL = "SELECT orders_contacts.contact_id, orders_contacts.form_id, org_name, first_name, last_name, address1, address2, city, state, " & _
"zip, email, phone, DATE_FORMAT(date_added, '%Y-%m-%d %T') AS date_added " & _
"FROM orders_contacts INNER JOIN orders_order ON orders_contacts.contact_id = orders_order.contact_id " & _
"WHERE " & strCriteria
Set rsCopy3 = OAMySQLConn.OpenRecordset(strSQL)
Do While Not rsCopy3.EOF
strSQL = "INSERT INTO orders_contacts (contact_id, form_id, org_name, first_name, last_name, address1, " & _
"address2, city, state, zip, email, phone, date_added) " & _
"VALUES (" & rsCopy3!contact_id & ", " & rsCopy3!form_id & ", " & Chr(34) & rsCopy3!org_name & Chr(34) & _
", " & Chr(34) & rsCopy3!first_name & Chr(34) & ", " & Chr(34) & rsCopy3!last_name & Chr(34) & _
", " & Chr(34) & rsCopy3!address1 & Chr(34) & ", " & Chr(34) & rsCopy3!address2 & Chr(34) & _
", " & Chr(34) & rsCopy3!city & Chr(34) & ", " & Chr(34) & rsCopy3!state & Chr(34) & _
", " & Chr(34) & rsCopy3!zip & Chr(34) & ", " & Chr(34) & rsCopy3!email & Chr(34) & _
", " & Chr(34) & rsCopy3!phone & Chr(34) & ", " & Chr(34) & rsCopy3!date_added & Chr(34) & ")"
MySQLConn.Execute (strSQL)
rsCopy3.MoveNext
Loop
rsCopy3.Close
Else
DoCmd.Hourglass False
Dim RS0 As Recordset
Set RS0 = CurrentDb.OpenRecordset("log_Errors")
RS0.AddNew
RS0("error_loc") = "ZERO publication orders submitted online for " & strODBCdate
RS0("error_time") = Now()
RS0.Update
RS0.Close
Set RS0 = Nothing
End If
strSQL = "UNLOCK TABLES"
OAMySQLConn.Execute (strSQL)
DoCmd.Hourglass False
Dim RS10 As Recordset
Set RS10 = CurrentDb.OpenRecordset("log_Errors")
RS10.AddNew
RS10("error_loc") = "Import publications completed without error"
RS10("error_time") = Now()
RS10.Update
RS10.Close
Set RS10 = Nothing
DoCmd.SetWarnings True
Exit Sub
ErrorHandler:
DoCmd.Hourglass False
Dim RS2 As Recordset
Set RS2 = CurrentDb.OpenRecordset("log_Errors")
RS2.AddNew
RS2("error_loc") = "procedure ImportPubOrders"
RS2("error_num") = Err.Number
RS2("error_desc") = Err.Description
RS2("error_time") = Now()
RS2.Update
RS2.Close
Set RS2 = Nothing
Set rsCopy1 = Nothing
Set rsCopy2 = Nothing
Set rsCopy3 = Nothing
DoCmd.SetWarnings True
サブ終了