WddxRecordset Object

The WddxRecordset object includes functions that you call as needed when constructing a WDDX recordset.

addColumn

Adds the specified column to all rows in the WddxRecordset instance.

Syntax

object.addColumn( name )
object

Instance name of the WddxRecordset object.

name

Name of the column to add.

Return value

None.

Usage

This function adds the specified column to every row of the WDDX record set. Initially the new column's values are set to NULL.

Example

This example calls the addColumn function:

// create a new recordset
rs = new WddxRecordset();

// add a new column
rs.addColumn("NewColumn");

// extend the recordset by 3 rows
rs.addRows(3);

// set an element in the first row
// newValue is a previously defined variable
rs.setField(0, "NewColumn", newValue);

addRows

Adds the specified number of rows to all columns in the WddxRecordset instance.

Syntax

object.addRows( n )
object

Instance name of the WddxRecordset object.

n

Integer specifying the number of rows to add.

Return value

None.

Usage

This function adds the specified number of rows to every column of the WDDX record set. Initially, the row/column values are set to NULL.

Example

This example calls the addRows function:

// create a new recordset
rs = new WddxRecordset();

// add a new column
rs.addColumn("NewColumn");

// extend the recordset by 3 rows
rs.addRows(3);

// set an element in the first row
// newValue is a previously defined variable
rs.setField(0, "NewColumn", newValue);

getField

Returns the element in the specified row/column position.

Syntax

object.getField( row, col )
object

Instance name of the WddxRecordset object.

row

Integer specifying the zero-based row number of the value to be returned.

col

Integer or string specifying the column of the value to be returned.

Return value

Returns the value in the specified row/column position.

Usage

Call this function to access a value in a WDDX record set.

Example

This example calls the getField function (the variable r is a reference to a WddxRecordset instance):

for (row = 0; row < nRows; ++row)
{
  o += "<tr>";
  for (i = 0; i < colNames.length; ++i)
  {
    o += "<td>" + r.getField(row, colNames[i]) + "</td>";
  }
  o += "</tr>";
}

getRowCount

Indicates the number of rows in the WddxRecordset instance.

Syntax

object.getRowCount( )
object

Instance name of the WddxRecordset object.

Return value

Integer. Returns the number of rows in the WddxRecordset instance.

Usage

Call this function before a looping construct to determine the number of rows in the record set.

Example

This example calls the getRowCount function:

function dumpWddxRecordset(r)
{ 
// Get row count 
    nRows = r.getRowCount();
...
    for (row = 0; row < nRows; ++row)
...

setField

Sets the element in the specified row/column position.

Syntax

object.setField( row, col, value )
object

Instance name of the WddxRecordset object.

row

Integer specifying the row containing the element to be set.

col

Integer or string specifying the column containing the element to be set.

value

Value to be set.

Return value

None.

Usage

Call this function to set a value in a WddxRecordset instance.

Example

This example calls the setField function:

// create a new recordset
rs = new WddxRecordset();

// add a new column
rs.addColumn("NewColumn");

// extend the recordset by 3 rows
rs.addRows(3);

// set an element in the first row
// newValue is a previously defined variable
rs.setField(0, "NewColumn", newValue);

wddxSerialize

Serializes a record set.

Syntax

object.wddxSerialize( serializer )
object

Instance name of the WddxRecordset object.

serializer

WddxSerializer instance.

Return value

Boolean. Returns True if serialization was successful and False if an error occurs.

Usage

Internal. You do not typically call this function.

Example

This example is from the WddxSerializer serializeValue function:

...
else if (typeof(obj) == "object")
{
  if (obj == null)
  {
    // Null values become empty strings
    this.write("<string></string>");
  }
  else if (typeof(obj.wddxSerialize) == "function")
  {
    // Object knows how to serialize itself
    bSuccess = obj.wddxSerialize(this);
  }
...


1