[Contents]


ResultSet

Object. ResultSet objects are used to access the results of a database action. These objects can not be created manually, but must be retrieved through the LassoSession object to which the set belongs. A ResultSet object can only be used after its LassoSession object has been executed.


Properties

The ResultSet object has the following properties:

Property

Description

Column Name Properties Properties which allow access to the ResultSet's database data.

Methods

The ResultSet object has the following methods:

Method

Description

close Closes the ResultSet so that the database data is no longer accessible.
columns Returns the number of columns in the ResultSet.
next Advances the row marker to the next row is possible.
columnName Returns the name of the specified column.
columnType Returns the data type for the specified column.
columnProtection Returns the protection for the specified column.
listValues Returns the value list associated with a particular column.
repeats Returns true if the specified column is repeating.
related Returns true if the specified column is a related column.
foundCount Returns the number of records found as a result of the database activity.
shownCount Returns the number of records whose data is available as a result of the database activity.


Column Name Properties

Properties. After a session has executed, the session's ResultSet has zero or more properties defined to allow access to the database data. These properties are named after the columns themselves, so they will vary depending on the database which was accessed.

Examples

This example gets the ResultSet from the default session and prints out the column data for the current row. The database has the following columns defined: Field1, Field2, Field3 and Field4.

var mySet = lasso.defaultSession.getResultSet();
if ( mySet.next() ) // move us to the first row
{
    write( "Field1: ", mySet.Field1, "<BR>" );
    write( "Field2: ", mySet.Field2, "<BR>" );
    write( "Field3: ", mySet.Field3, "<BR>" );
    write( "Field4: ", mySet.Field4, "<BR>" );
}

If a column name has characters which are illegal in JavaScript property names (such as a related column containing "::"), the column's data can be accessed using the subscript operator with the quoted column name passed as the index.

This example gets the ResultSet from the default session and prints out the column data for the current row. The database has the following columns defined: Relation::Field1, Relation::Field2, Relation::Field3 and Relation::Field4.

var mySet = lasso.defaultSession.getResultSet();
if ( mySet.next() ) // move us to the first row
{
    write( "Relation::Field1: ", mySet[ "Relation::Field1" ], "<BR>" );
    write( "Relation::Field2: ", mySet[ "Relation::Field2" ], "<BR>" );
    write( "Relation::Field3: ", mySet[ "Relation::Field3" ], "<BR>" );
    write( "Relation::Field4: ", mySet[ "Relation::Field4" ], "<BR>" );
}


close

Method. This method closes the ResultSet so that the database data is no longer available.

Syntax

close()

Parameters

None.

Returns

Nothing.

Description

This method closes the ResultSet so that the database data is no longer available. It also enables the ResultSet's LassoSession object to be executed again. close must be called before a session can be re-executed.

Examples

This example checks to see if the default session has been executed. If it has, it closes the session's ResultSet and re-executes the session.

if ( lasso.defaultSession.hasExecuted() )
{
    var mySet = lasso.defaultSession.getResultSet();
    mySet.close();
} lasso.defaultSession.execute();

columns

Method. This method returns the number of columns (fields) available in the ResultSet.

Syntax

columns()

Parameters

None.

Returns

The number of available columns.


next

Method. This method advances to the next row (record) if possible.

Syntax

next()

Parameters

None.

Returns

False if the current row is the last row and true if the ResultSet was advanced to the next row.

Description

This method is used to iterate through the rows in the result set. Initially, the ResultSet row marker is positioned before the first row. Next must be called at least once before any database data can be accessed.

Examples

This example iterates through all the rows in the ResultSet and outputs the number of rows.

var mySet = lasso.defaultSession.getResultSet();
var count = 0;
while (  mySet.next() )
    ++count;
write( "There are ", count, " rows in the set." );

columnName

Method. This method returns the name of the specified column (field).

Syntax

columnName( columnIndex )

Parameters

columnIndex is the zero based index of the column.

Returns

The name of the column if the specified index is valid.

Description

This method is used to determine the name of a column based on its index.

Examples

This example will output the name of every column in the ResultSet.

var mySet = lasso.defaultSession.getResultSet();
for ( var x = 0; x < mySet.columns(); ++x )
{
    write( "Column ", x + 1, ": ", mySet.columnName( x ), "<BR>" );
}

columnType

Method. This method returns the data type of the specified column (field).

Syntax

columnType( columnIndex )
columnType( columnName )

Parameters

columnIndex is the zero based index of the column.
columnName is the name of the column.

Returns

A string containing the data type of the column if the specified index is valid. The returned string will contain one of the following values:

text
image
boolean
date/time
number
unknown

Description

This method is used to determine the data type of a column based on its index.

Examples

This example will output the data type of every column in the ResultSet.

var mySet = lasso.defaultSession.getResultSet();
for ( var x = 0; x < mySet.columns(); ++x )
{
    write( "Column ", x + 1, ": ", mySet.columnType( x ), "<BR>" );
}

columnProtection

Method. This method returns the protection type of the specified column (field).

Syntax

columnProtection( columnIndex )
columnProtection( columnName )

Parameters

columnIndex is the zero based index of the column.
columnName is the name of the column.

Returns

A string containing the protection type of the column if the specified index is valid. The returned string will contain one of the following values:

none
read only

Description

This method is used to determine the protection type of a column based on its index.

Examples

This example will output the protection type of every column in the ResultSet.

var mySet = lasso.defaultSession.getResultSet();
for ( var x = 0; x < mySet.columns(); ++x )
{
    write( "Column ", x + 1, ": ", mySet.columnProtection( x ), "<BR>" );
}

listValues

Method. This method returns value list associated with a column (field).

Syntax

listValues( columnIndex )
listValues( columnName )

Parameters

columnIndex is the zero based index of the column.
columnName is the name of the column

Returns

An array of possible values for the column.

Description

This method is a FileMaker specific extension to the ResultSet object and can be ignored when using other datasources. It provides access to the value list associated with a column. If the column does not have a value list, the list returned by this method will be empty.

If a column does have a value list and has multiple values in the field data, the data for the column will be an array of values.


repeats

Method. This method is used to determine if a column (field) is repeating.

Syntax

repeats( columnIndex )
repeats( columnName )

Parameters

columnIndex is the zero based index of the column.
columnName is the name of the column.

Returns

True if the column is repeating, false, otherwise.

Description

This method is a FileMaker specific extension to the ResultSet object and can be ignored when using other datasources. It is used to determine if a column has repeating values.

If a column does have repeating values and there are multiple values in the field data, the data for the column will be an array of values.


related

Method. This method is used to determine if a column is a related column (field).

Syntax

related( columnIndex )
related( columnName )

Parameters

columnIndex is the zero based index of the column.
columnName is the name of the column.

Returns

True is the column is related, otherwise, false.

Description

This method is a FileMaker specific extension to the ResultSet object and can be ignored when using other datasources. It is used to determine if a column is related.

If a column is related and has multiple related values, the data for the column will be returns as an array of values.


foundCount

Method. This method is used to determine the number of database records which were found when the session was executed.

Syntax

foundCount()

Parameters

None.

Returns

The number of records that were found.

Description

This function can be used to determine how many records were found as the result of a search. The number of found records is not necessarily the number of records whose data is available (the number of shown records).

Examples

This example will output the number of records found as a result of the previous database activity.

var mySet = lasso.defaultSession.getResultSet();
write( "The number of found records is: ", mySet.foundCount() );


shownCount

Method. This method is used to determine the number of database records whose data is available in the current ResultSet object.

Syntax

shownCount()

Parameters

None.

Returns

The number of records that are available.

Description

This function can be used to determine how many records are available in the current ResultSet object. This number will be equal to the number of times the ResultSet object's next function can be called.

Examples

This example will output the number of records that are available in the result set.

var mySet = lasso.defaultSession.getResultSet();
write( "The number of records available is: ", mySet.shownCount() );