Execute Method

Log Parser

Execute Method

Executes a query and returns a LogRecordSet object that can be used to navigate through the query output records.

Script Syntax

objRecordSet = objLogQuery.Execute(strQuery [, objInputFormat ]);


Parameters

strQuery
A string containing the text of the SQL-Like query to be executed.
objInputFormat
Either an Input Format object or a Custom Input Format Plugin object.
If this parameter is not specified, or is null, Log Parser will attempt to select automatically an input format upon inspection of the <from-entity> in the FROM clause of the specified query.


Return Value

A LogRecordSet object, which can be used to navigate through the query output records.


Remarks

  • If the query execution encounters errors, an exception is thrown containing the error message and code, and the query execution is aborted.
    In this case, the lastError property of the LogQuery object is set to -1, and the collection of strings returned by the errorMessages property contains the error message.
  • If the query execution encounters parse errors or warnings, the query executes successfully, and the method returns a LogRecordSet object.
    In this case, the lastError property of the LogQuery object is set to -1, and the collection of strings returned by the errorMessages property contains the parse error messages and/or warning messages.
  • A successful execution of the Execute method does not necessarily mean that the query execution has completed.
    Depending on the query structure, navigating the query output records with the LogRecordSet object can cause the query to further process new input records, which could in turn generate additional errors, parse errors, or warnings. See the LogRecordSet Object Reference for more information.
  • The specified query can not contain an INTO clause.


Examples

JScript example:

var oLogQuery = new ActiveXObject("MSUtil.LogQuery");

// Create Input Format object
var oIISW3CInputFormat = new ActiveXObject("MSUtil.LogQuery.IISW3CInputFormat");

// Create query text
var strQuery = "SELECT c-ip FROM <1> WHERE cs-uri-stem LIKE '%hitcount.asp'";

// Execute query and receive a LogRecordSet
var oRecordSet = oLogQuery.Execute( strQuery, oIISW3CInputFormat );

// Visit all records
while( !oRecordSet.atEnd() )
{
	// Get a record
	var oRecord = oRecordSet.getRecord();

	// Get first field value
	var strClientIp = oRecord.getValue( 0 );

	// Print field value
	WScript.Echo( "Client IP Address: " + strClientIp );

	// Advance LogRecordSet to next record
	oRecordSet.moveNext();
}

// Close LogRecordSet
oRecordSet.close();

VBScript example:

Dim oLogQuery
Dim oIISW3CInputFormat
Dim strQuery
Dim oRecordSet
Dim oRecord
Dim strClientIp

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Create Input Format object
Set oIISW3CInputFormat = CreateObject("MSUtil.LogQuery.IISW3CInputFormat")

' Create query text
strQuery = "SELECT c-ip FROM <1> WHERE cs-uri-stem LIKE '%hitcount.asp'"

' Execute query and receive a LogRecordSet
Set oRecordSet = oLogQuery.Execute ( strQuery, oIISW3CInputFormat )

' Visit all records
DO WHILE NOT oRecordSet.atEnd

	' Get a record
	Set oRecord = oRecordSet.getRecord

	' Get first field value
	strClientIp = oRecord.getValue ( 0 )

	' Print field value
	WScript.Echo "Client IP Address: " & strClientIp

	' Advance LogRecordSet to next record
	oRecordSet.moveNext

LOOP

' Close RecordSet
oRecordSet.close


See also:

LogQuery Object
ExecuteBatch Method
LogRecordSet Object
Input Format Objects
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.