dim strsql,compcodesql,path
set orapara=wscript.createobject("wscript.shell")
on error resume next
'當前路徑
path = createobject("scripting.filesystemobject").getfolder(".").path
'檔案處理物件
set pofso = createobject("scripting.filesystemobject")
'資料庫連線
set con = createobject("adodb.connection")
'db連線引數
'data source : tnsnames.ora 配置service對應的監聽名 root
'root =
' (description =
' (address = (protocol = tcp)(host = localhost)(port = 1521))
' (connect_data =
' (server = dedicated)
' (service_name = root)
' )
' )
con.connectionstring = "provider=oraoledb.oracle.1;password=***;user id=***;data source=***;persist security info=true"
compcodesql = " "
'get_sql是儲存過程名 沒有直接定義sql是為了省去vb轉義的麻煩 用plsql的字串模板
' select q'| 中間可以直接賦值大段的sql文 |' from dual
compcodesql = compcodesql & " select get_sql from dual" 'column index 0,1'
'db連線狀態
con.open
if con.state = 0 then
msgbox("db連線成功")
on error goto 0
else
msgbox("db連線失敗")
end if
'當前時間
dim sysdate
dim mm
dim dd
dim csvtitle
dim psbuff
mm = month(now)
dd = day(now)
if cint(mm) < 10 then
mm = "0" & cstr(mm)
end if
if cint(dd) < 10 then
dd = "0" & cstr(dd)
end if
sysdate = year(now) & mm & dd
'sql執行
set strval = con.execute(compcodesql)
'要執行的sql
strsql = strval.fields(0)
'msgbox(strsql)
'輸出結果用於賦值
set csvval = con.execute(strsql)
if isobject(pvehtxtfile) then
pvehtxtfile.close
set pvehtxtfile = nothing
end if
if isobject(pvehtxtfilebackup) then
pvehtxtfilebackup.close
set pvehtxtfilebackup = nothing
end if
'csv檔案輸出路徑定義
set pvehtxtfile = pofso.createtextfile(path & "\csv" & sysdate & ".csv",true)
'csv檔案列名定義
csvtitle = ""
csvtitle = " isr名 "
for i = 1 to 19 step 1
csvtitle = csvtitle & " isr名 "& i & ","
next
pvehtxtfile.writeline csvtitle
pvehtxtfilebackup.writeline csvtitle
'csv賦值
if csvval.eof = false then
csvval.movefirst
do until csvval.eof
psbuff = ""
set fld = nothing
set fld = csvval.fields
for i = 0 to fld.count - 1 step 1
psbuff = psbuff & csvval.fields(i) & ","
next
pvehtxtfile.writeline psbuff
pvehtxtfilebackup.writeline psbuff
csvval.movenext
loop
end if
msgbox("end")
msgbox(path)
oracle 匯入匯出 遠端連線
exp本地匯出與imp本地匯入 exp命令 1 exp username psw test file d test.dmp full y 2 exp username psw test file d test.dmp owner ly 3 exp username psw test file d t...
oracle匯出,匯入
匯出,在dos下執行 1.exp username userpassword databasename 可以是資料庫也可是遠端的,如username userpassword caac135 2.enter array fetch buffer size 4096 回車 3.export file ...
ORACLE匯出序列
最近遇到oracle匯出序列時有問題 即序列的當前值和資料庫中一些表的id最大值不一致,我們的資料庫表的主鍵是從序列中取的 需要重新匯入序列,發現exp不能單獨匯出序列,由於資料量龐大,所以又不想再導一遍資料。在網上搜尋了一下找到乙個比較好的辦法 第一步 在原資料庫上執行如下語句 select cr...