I posted this to microsoft.public.win2000.cmdprompt.admin on January
5, where I was advised to "try re-posting in a WSH or SQL newsgroup".
I posted to microsoft.public.scripting.vbscript on January 6 and was
advised to post here, where "... the logParser dudes hang out." So
here goes...
I'm using LogParser 2.1 as a COM object under W2K SP4 via VBS scripts.
I'd like to be able to execute Log Parser on a first pass to obtain a
record set and then pass that cursor back to Log Parser as *input* for
a second query.
Here's a very simple example just for illustrative purposes:
Dim Wshso, oEvtLogQ, strSQL, strSQL2, oRS, oRS2
Set Wshso = WScript.CreateObject("WScript.Shell")
Set oEvtLogQ = WScript.CreateObject("MSUtil.LogQuery")
'count all SysLog 6005 incidents
strSQL = "SELECT COUNT(*) FROM System WHERE EventID = 6005"
Set oRS = oEvtLogQ.Execute(strSQL)
'display the count
MsgBox oRS.GetRecord().getValue(0)
Set oRS=Nothing 'clear oRS for reuse
'redo the same query in two parts
'select all SysLog 6005 incidents into oRS cursor
strSQL = "SELECT EventID FROM System WHERE EventID = 6005"
Set oRS = oEvtLogQ.Execute(strSQL)
'display the first record to confirm the query returned something
MsgBox oRS.GetRecord().getValue(0)
'count all SysLog 6005 incidents using oRS cursor as input
strSQL2 = "SELECT COUNT(*) FROM " & oRS & " GROUP BY EventID"
Set oRS2 = oEvtLogQ.Execute(strSQL2)
'display the count
MsgBox oRS2.GetRecord().getValue(0)
The first two queries complete successfully and the message boxes
display normally. The third query returns an error and points to the
strSQL2 assignment line:
Error: Object doesn't support this property or method
Code 800A01B6
What would be the correct syntax to use the oRS cursor as input to the
second query?
LogParser is a wonderful tool. (Kudos to the team that developed it.)
Being able to use cursors in VBS scripts would allow me to use it as a
"pocket" SQL engine to perform virtually any conceivable analysis of
any line-record log file. (Without the use of cursors, the same
analysis could still be performed, but the intermediate query results
would need to be saved to files.)
regards, Andy
**********
Please send e-mail to: usenet d0t post at aaronoff d0t com
**********