0

テキストファイルから読み取った後、変数に格納された値を使用してSQLplusに接続し、テーブルを更新しようとしていますが、エラーが発生します:"未終了の文字列定数これは、Guidoの支援に感謝します。ステップ1で私を指摘してください。誰かがエラーを指摘できますか。If&Else Part内のエラー、SQLクエリまたは接続が間違っています。

dim fs, txt, line, yesno , cust_id
set fs = CreateObject("Scripting.FileSystemObject")
set txt = fs.OpenTextFile("E:\batchfiletest\Eapp3\scotia1.txt", 1, false) 

' loop through all the lines
do while not txt.AtEndOfStream
    line = txt.readLine

' read the character and store it in a variable
    yesno = Mid(line, 127, 1)
    cust_id = Mid(line, 1,20)   

' execute the correct query
    if yesno = "Y" then

    set WshShell = CreateObject("WScript.Shell")
    set oEnv=WshShell.Environment("Process") 
    cmdString = "E:\oracle\product\10.2.0\db_1\BIN\sqlplusw.exe -S sysman/csaadmin@convcsd

    UPDATE csa_sli_all.T_CONV_quote set HOLD_CODE = 'CAQ' where quote_id =  cust_id ;
    commit;"

    Set oExec = WshShell.Exec(cmdString)

     ELSE  
    set WshShell = CreateObject("WScript.Shell")
    set oEnv=WshShell.Environment("Process") 
    cmdString = "E:\oracle\product\10.2.0\db_1\BIN\sqlplusw.exe -S sysman/csaadmin@convcsd

    UPDATE csa_sli_all.T_CONV_quote set HOLD_CODE = 'PVQ' where quote_id =  cust_id ;
    commit;"

    Set oExec = WshShell.Exec(cmdString)

    end if
loop
MsgBox "Press OK to close when done reading the output."
4

1 に答える 1

1

これを行うための通常のより速くより安全な方法は次のようなものです

Const sConnectionStringOracle =  "Provider=OraOLEDB.Oracle;Data Source=xxxx.xxxxx;User id=xxx;password=xxx"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.open sConnectionStringOracle
sql = "UPDATE csa_sli_all.T_CONV_quote set HOLD_CODE = 'CAQ' where quote_id = " & cust_id
oConn.execute(sql)
'rest of the database transactions
oConn.close
Set oConn = nothing

エラートラップ、ロギングなどを追加できます。これを使用するPCにOracleOleDbドライバがインストールされていることを確認してください。Sql * Plusを使用する必要がある場合は、すべてのトランザクションを1つのSQLテキストファイルに書き込み、それを1回だけ実行します。その後、エラーが発生した場合にSQLを実行してデバッグできます。

Grtz

于 2012-04-12T11:15:20.003 に答える