| ' **********************************************************
' オブジェクト作成
' **********************************************************
Set OraSession = CreateObject( "OracleInProcServer.XOraSession" )
Set Fs = CreateObject( "Scripting.FileSystemObject" )
' **********************************************************
' 接続
' **********************************************************
on error resume next
OraSession.CreateDatabasePool 1,40,200,"lightbox", "lightbox/lightbox", 0
if Err.Number <> 0 then
Wscript.Echo OraSession.LastServerErrText
Wscript.Quit
end if
on error goto 0
Set OraDatabase = OraSession.GetDatabaseFromPool(10)
OraDatabase.LastServerErrReset
' **********************************************************
' レコードセット取得
' **********************************************************
Query = "select * from 社員マスタ"
on error resume next
Set OraDynaset = OraDatabase.CreateDynaset(Query,2)
if Err.Number <> 0 then
Wscript.Echo OraDatabase.LastServerErrText
Wscript.Quit
end if
on error goto 0
' **********************************************************
' 出力ファイルオープン
' **********************************************************
Set Csv = Fs.CreateTextFile( "社員マスタ.csv", True )
' **********************************************************
' タイトル出力
' **********************************************************
Buffer = ""
For i = 0 to OraDynaset.Fields.Count - 1
if Buffer <> "" then
Buffer = Buffer & ","
end if
Buffer = Buffer & OraDynaset.Fields(i).Name
Next
Csv.WriteLine Buffer
' **********************************************************
' データ出力
' **********************************************************
Do While not OraDynaset.EOF
Buffer = ""
For i = 0 to OraDynaset.Fields.Count - 1
if Buffer <> "" then
Buffer = Buffer & ","
end if
Buffer = Buffer & OraDynaset.Fields(i).Value
Next
Csv.WriteLine Buffer
OraDynaset.MoveNext
Loop
' **********************************************************
' ファイルクローズ
' **********************************************************
Csv.Close
' **********************************************************
' オブジェクト解放
' **********************************************************
Set Fs = Nothing
Set OraDynaset = Nothing
Set OraDatabase = Nothing
Set OraSession = Nothing
| |