Siebel Analytics Scheduler Guide > Using Siebel Analytics Scheduler > Working with Job Scripts >

Working with the Siebel Object


A Siebel object represents an active connection to a Siebel Analytics Server. This is the object returned by the NQSConnect() method of the Script object.

Read-Only Siebel Object Properties

This section describes the read-only Siebel object properties.

Query

Returns the query string used to select records for the record set of a Siebel object. This is not a valid string until after issuing a call to OpenRecordset().

Return Value: returns a string value.

Empty

Returns True if there are no records in the record set of a Siebel object.

Return Value: returns a boolean value.

EOF

Returns True if the record set cursor is positioned after the last record.

Return Value: returns a boolean value.

FieldCount

Returns the number of fields in the record set.

Return Value: returns an Integer value.

FieldName (index)

Returns the name of a specific field in the record set of a Siebel object.

where:

index

The zero-based index of the field.

Return Value: returns a string value.

Field(index)

Returns the value of a specific field in the record set of a Siebel object.

Syntax:

Syntax 1          Field ( index )

Syntax 2          Field ( fieldName )

where:

index

The zero-based index of the field.

fieldName

The name of the field.

Return Value: returns a variant value.

Read/Write Siebel Object Properties

This section describes the read/write Siebel object properties.

MaxRows

Sets or returns the maximum rows to retrieve.

Settings and return value: sets or returns a long value. The default value of 0 (zero) specifies that any number of rows is acceptable.

CacheSize

Sets or returns the maximum rows to cache in memory for a query operation.

Settings and return value: sets or returns a long value. The default value is 0 (zero).

Siebel Object Methods

This section describes the Siebel object methods.

OpenRecordset

Opens a record set by executing the given query.

Syntax:

OpenRecordset query [, timeout]

where:

query

A string that specifies the SQL statement to execute.

timeout

Optional. A long value that specifies the number of seconds to wait for the query execution to complete. The default is 30. Specifying 0 (zero) will cause the call to block until a result set exists.

Usage Notes: Call this method to send a query and retrieve results from a Siebel data source.

CloseRecordset

Closes the current record set.

Syntax:

CloseRecordset

Usage Notes: Call this method to close a previously opened record set.

Next

Moves the cursor to the next record in a record set.

Syntax:

Next

Usage Notes: Call this method to move the cursor to the next record. If the cursor is moved past the last record, the EOF method will return True.

Example of NQSConnect Object

This section shows an example of an NQSConnect object.

/****************************************************
File:
     TestNQSConnect.js

Description:
    This is a job script that connects to an NQS
server, executes a query, and dumps the result set
to a file.

Parameters:

Parameter(0) specifies the output file Path.
Parameter(1) specifies a DSN to a Siebel server.
Parameter(2) specifies the query to execute.

*****************************************************/

/*** Create Output File ***/
var fso = new ActiveXObject("Scripting.FileSystemObject");
var filename = Parameter(0) + "\\" + "output." + JobID + "." +
     InstanceID + ".txt";
var a = fso.CreateTextFile(filename, true);

/*** Dump Job Attributes ***/
a.WriteLine("Script: TestNQSConnect.js");
a.WriteLine("JobID: " + JobID.toString());
a.WriteLine("InstanceID: " + InstanceID.toString());
a.WriteLine("UserID: " + UserID);
a.WriteLine("ParameterCount: " + ParameterCount.toString());

/*** Connect to Server ***/
a.Write("Connecting to " + Parameter(1) + " ... ");
var nqs = NQSConnect(Parameter(1));
a.WriteLine("OK");

/*** Execute Query ***/
a.Write("Executing query \"" + Parameter(2) + "\" ... ");
nqs.OpenRecordset(Parameter(2), 0);
a.WriteLine("OK");

/*** Dump Column Names ***/
var sep = "\t";
var i;
for (i=0; i<nqs.FieldCount; ++i)
{
     a.Write(nqs.FieldName(i) + sep);
}
a.WriteLine();

/*** Dump Result Set ***/
while (!nqs.EOF)
{
     for (i=0; i<nqs.FieldCount; i++)
     {
          a.Write(String(nqs.Field(i)) + sep);
     }
     a.WriteLine();
     nqs.Next();
}

/*** Close Result Set ***/
nqs.CloseRecordset();

/*** Close Output File ***/
a.Close();

function OnError()
{
     a.Close();
}


 Siebel Analytics Scheduler Guide 
 Published: 18 April 2003