| <JOB>
<OBJECT id="Fso" progid="Scripting.FileSystemObject" />
<OBJECT id="OraSession" progid="OracleInProcServer.XOraSession" />
<REFERENCE guid="F2D4ED20-FFD3-101A-ADF2-04021C007002" />
<SCRIPT language=VBScript>
Dim OraDatabase,OraDynaset
' ***********************************************************
' 処理開始
' ***********************************************************
' GUI
if vbCancel = MsgBox( "処理を開始しますか? ", vbOKCancel , "サンプル" ) then
Wscript.Echo "キャンセルされました"
Wscript.Quit
end if
' REFERENCE 要素定義の為可能な定数参照
Wscript.Echo "ORADB_DEFAULT = " & ORADB_DEFAULT
Wscript.Echo "ORADB_ORAMODE = " & ORADB_ORAMODE
Wscript.Echo "ORADB_NOWAIT = " & ORADB_NOWAIT
Wscript.Echo "ORADB_NO_REFETCH = " & ORADB_NO_REFETCH
Wscript.Echo "ORADB_NONBLK = " & ORADB_NONBLK
Wscript.Echo "ORADB_ENLIST_IN_MTS = " & ORADB_ENLIST_IN_MTS
Wscript.Echo "ORADB_ENLIST_FOR_CALLBACK = " & ORADB_ENLIST_FOR_CALLBACK
' "PC名/サービス", "ユーザ/パスワード"
Set OraDatabase = OraSession.OpenDatabase("night/xe", "LB/LB", ORADB_DEFAULT)
OraDatabase.LastServerErrReset
' **********************************************************
' レコードセット取得
' **********************************************************
Query = RegTrim(GetResource("myTextData"))
Wscript.Echo Query
Wscript.Echo "ORADYN_NO_BLANKSTRIP = " & ORADYN_NO_BLANKSTRIP
on error resume next
Set OraDynaset = OraDatabase.CreateDynaset(Query,ORADYN_NO_BLANKSTRIP)
if Err.Number <> 0 then
Wscript.Echo OraDatabase.LastServerErrText
Wscript.Quit
end if
on error goto 0
' **********************************************************
' 出力ファイルオープン
' **********************************************************
Set Csv = Fso.CreateTextFile( "ALL_DIRECTORIES.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 OraDynaset = Nothing
Set OraDatabase = Nothing
Wscript.Echo "処理が終了しました"
' ***********************************************************
' 文字列前後の漢字スペースを含むホワイトスペースの削除
' ***********************************************************
Function RegTrim( strValue )
Dim regEx, str
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Pattern = "^[ \s]+"
str = regEx.Replace( strValue, "" )
regEx.Pattern = "[ \s]+$"
RegTrim = regEx.Replace( str, "" )
End Function
</SCRIPT>
<COMMENT>
************************************************************
ソース内テキストデータ
************************************************************
</COMMENT>
<RESOURCE id="myTextData">
<![CDATA[
SELECT * FROM ALL_DIRECTORIES
]]>
</RESOURCE>
</JOB>
| |