我有一個txt文件在以下格式VB腳本讀取的文本文件和執行查詢
11SNMMMMTESTCASEJBS1961123123232YExist
從這個文件我要檢查在第33列中的值,這將是Y或N. 如果它是N,我得去數據庫,並使用下面的查詢
Update table XYZ set Status = Not Exist where cust_id = ** (taken from record)
如果爲Y
Update table XYZ set Status = Exist where cust_id = ** (taken from record)
後readi ng從一個文本文件,我想連接到SQLplus與存儲在一個變量的值,並試圖更新表,但我得到以下錯誤:「未終止的字符串常量 這是代碼的樣子,感謝Guido的幫助我出了第1步。 任何人都可以請指出錯誤。某些錯誤裏面如果& else部分,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/[email protected]
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/[email protected]
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."
你似乎會問SO寫你的代碼嗎? – 2012-04-10 08:48:52
指針可以幫助我,代碼更好:) – 2012-04-10 09:54:43
你看過我在下面的答案中包含的鏈接嗎?這是非常基本的代碼。讓我知道,如果這對你有用,否則我可以寫你一個例子。 – 2012-04-10 10:05:30