Eclipse BIRT Report Object Model (ROM)

ScriptDataSet Element

# Element Overview

A data set defined in JavaScript.

### Details

Display Name: | Script Data Set
Since: | 1.0
XML Element: | `script-data-set`
Extends: | SimpleDataSet
Extendable: | Yes
Abstract: | No
Name Space: | Data Sets
Name Requirement: | Required
Allows User Properties: | Yes
Has Style: | No

### Property Summary

dataSource
  The database connection that the data set is used.

### Method Summary

close
  Called by BIRT to close the data set.
describe
  Dynamically describes the result set definition in JavaScript.
fetch
  Fetches a row from the data set.
open
  Opens the data set.

### Inherited Properties

cachedMetaData, columnHints, comments, computedColumns, customXml, dataSetRowLimit, displayName, displayNameID, eventHandlerClass, extends, filter, name, needsCache, newHandlerOnEachEvent, paramBindings, parameters, propertyMasks, refTemplateParameter, resultSetHints, rowFetchLimit, sortHints, userProperties, viewAction

### Inherited Methods

beforeOpen, beforeClose, onFetch, afterOpen, afterClose

### Description

Represents a data set defined in JavaScript code, providing methods for opening, fetching and closing the data set. It defines the overall properties of the scripted data set including the JavaScript methods themselves and an optional result set definition.

# Property Detail

## dataSource Property

The database connection that the data set is used.

### Details

Type: | DataSource Reference
Since: | 1.0
Required: | Yes
Display Name: | Data source
JavaScript Type: |
Default Value: | None
Inherited: | Yes
Runtime Settable: | Yes
Property Sheet Visibility: | Visible
Property Sheet Group: | Top

### Description

Name of the data source, that is the database connection this data set is using.

### See Also

`DataSetParam structure`

`ParamBinding structure`

# Method Detail

## close Method

Called by BIRT to close the data set.

### Synopsis

`None obj.close( )`

### Details

Since: | 1.0
Context: | factory
Arguments: | None
Return Type: | None

### Description

Closes the data set. Optional.

### See Also

`beforeClose` method

`afterClose` method

## describe Method

Dynamically describes the result set definition in JavaScript.

### Synopsis

`ColumnDefn[] obj.describe( )`

### Details

Since: | reserved
Context: | factory
Arguments: | None
Return Type: | ColumnDefn[]

### Return

The Describe method can return null, which tells BIRT to use the static definition instead. The script can access the static description using the design object within the script.

If the method returns a column array, then the array must satisfy the following constraints:

- The array must have at least two entries,
- The entry in position 0 (which represents the row number column) is ignored.
- The entry in position 1 must exist.
- There must be no empty positions in the array.
- Each position must contain an object of type ResultSetColumn.
- The column names must be unique within the result set definition.
- Each column definition in the array must have a one-to-one match with the corresponding column in the DataRow object returned by the fetch method.

### Description

Called before BIRT calls the `beforeOpen` method. Creates a runt-time definition of the result set columns. Returns an array of ResultSetColumn objects. Each object describes a column in the expected result set. Optional.

### See Also

`ResultSetColumn` structure

## fetch Method

Fetches a row from the data set.

### Synopsis

`DataRow obj.fetch( )`

### Details

Since: | 1.0
Context: | factory
Arguments: | None
Return Type: | DataRow

### Return

Returns `true` if there is another row to fetch, `false` if there are no more rows. When the data set has returned the last row from the result set, subsequent calls to `fetch` should return `false`.

### Description

Fetches a row from the data set on each call, and populates the current row available in the `row` property.

### See Also

`onFetch` method

`DataRow scripting object`

## open Method

Opens the data set.

### Synopsis

`None obj.open( )`

### Details

Since: | 1.0
Context: | factory
Arguments: | None
Return Type: | None

### Description

Opens the external data set. Throws a JavaScript exception if the open fails. Often refers to report parameters or user-defined parameters for information about the data set. Optional.

### See Also

`beforeOpen` method

`afterOpen` method