User Guide > Scripting > Script Objects > DJRowSet Object Type
Was this helpful?
DJRowSet Object Type
The DJRowSet object is container for storing collections of record instances. A single DJRowSet object can store many different types of records. DJRowSet is both more flexible and more convenient for storing record images than arrays. Unlike arrays, each row in a row set can have a different number of elements. In effect, the row set is like a jagged array. Another advantage of row sets over arrays is that row sets have operations for inserting, appending, and deleting rows. With arrays, these operations require user-defined code.
Properties
 
Property
Type
Access
Description
FieldCount Property
Integer
RO
Return the number of fields in row rowno.
Self Property
DJRowSet
RO
Return a reference to the row set object.
Size Property
Integer
RO
Return the number of rows in the row set.
TypeName Property
String
RW
Get/set the record type name for the row rowno of the row set.
Value Property
Variant
RW
Get/set the value for the field fldno of the row rowno (default).
FieldCount Property
The FieldCount property returns an integer value with the number of fields in specified row of the row set.
Syntax
rowset.FieldCount(rowno)
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Integer
Yes
Index for the row in the row set.
Exceptions
The FieldCount method may return the following exceptions if there is an error at run time:
Exception
Description
ERR_TYPEMISMATCH
Returned if the row index is invalid.
Example
'The following example gets the number of fields for the 3rd record in the row set.
fcnt = rs.FieldCount(3)
Self Property
The Self property is used for getting a reference to an object that can then be passed as an argument to a function or method call. The reason for having a special property for getting the object reference is to resolve an ambiguity with the default property, Value. This is similar to the distinction between normal variable assignment (Let) the use of Set for assigning object variables. When a DJRowSet object variable is used without an associated property or method, the integration language processor assumes an implied access of the Value property.
Syntax
rowset.Self
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object which is the subject of the property or method invocation.
Example
The following example shows how the Self property might be used when copying data from a row set to a record.
'In this example, rec is a DJRecord variable and rs is a DJRowSet variable. The following would copy the contents of the third row of rs to the fields in rec.
rec.Copy(rs.Self, 3, True)
Size Property
The Size property is used to determine how many rows are stored in a DJRowSet container.
Syntax
rowset.Size
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Example
'The following example clears the row set, rs, if it contains any rows.
If rs.Size > 0 Then rs.Clear
TypeName Property
Get or set the record type name for a row in a row set. The DJRowSet can contain record images for many different types of records. The TypeName property is used to identify type of each record.
Syntax
rowset.TypeName(rowno)
'OR
rowset.TypeName(rowno) = name
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object which is the subject of the property or method invocation.
Integer
Yes
Index for the row in the row set.
String
Yes
Record type name.
Exceptions
The TypeName method may return the following exceptions if there is an error at run time:
Exception
Description
ERR_TYPEMISMATCH
Returned if the row index is invalid.
Example
'The following example sets the record type name for the third record in the row set to "Header".
rs.TypeName(3) = "Header"
Value Property
Get or set the field value for a field in a row stored in a row set.
Syntax
rowset.Value(rowno, fldno)
'OR
rowset.Value(rowno, fldno) = value
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Integer
Yes
Index for the row in the row set.
Integer
Yes
Index for the field in the selected row.
Variant
Yes
Value to assign to the field.
Exceptions
The Value method may return the following exceptions if there is an error at run time:
Exception
Description
ERR_TYPEMISMATCH
Returned if either the row or field index is invalid.
Example
'The following example sets the value for the tenth field of the second row:
rs.Value(2, 10) = "Row 2, Field 10 data"
Methods
 
Method
Description
Append Method (record)
Append a new row using the contents of a DJRecord object.
Append Method (Values)
Append a new row using the contents of a DJRecord object.
 
Clear Method
Clear all rows from the row set.
Erase Method
Erase row rowno from the row set.
Insert Method (rowno, record)
Insert a new row as row rowno using the list of records. rowno can be any integer value from 1 through Size + 1.
Insert Method (rowno, values)
Insert a new row as row rowno using the list of values. rowno can be any integer value from 1 through Size + 1.
Append Method
The Append method adds a new row to a row set. The new row is created using a list of values or by copying values from a DJRecord object.
Syntax
rowset.Append(record)
'OR
rowset.Append(values)
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
DJRecord
Yes
Reference to the DJRecord used to append a new row to the row set.
Variant
Yes
Comma-delimited list of values used as field values for a new row in the row set.
Exceptions
The Append method may return the following exceptions if there is an error at run time.
Exception
Description
ERR_TYPEMISMATCH
Returned if any invalid parameters are passed to the method.
Example
'The following example creates a new DJRowSet object and appends a couple of rows.
Dim rs As DJRowSet
Set rs = New DJRowSet
'Append the values from the current source record
rs.Append (RecordAt("/SOURCES/1").Self)
'Append a row with two text strings
rs.Append("This is one field value","This is another")
Clear Method
The Clear method removes all rows from a row set.
Syntax
rowset.Clear
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Example
'The following example clears the row set rs if there are any rows in the row set.
If rs.Size > 0 Then rs.Clear
Erase Method
The Erase method is used to erase a row from a row set. The row is specified using the rownum parameter.
Syntax
rowset.Erase(rownum)
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Integer
Yes
Row index of the row to be erased.
Exceptions
The Erase method may return the following exceptions if there is an error at run time:
Exception
Description
ERR_TYPEMISMATCH
Returned if an invalid row index is passed to the method.
Example
'The following example erases the last row of the row set rs if there are any rows in the row set.
If rs.Size > 0 Then rs.Erase(rs.Size)
Insert Method
The Insert method inserts a new row in a row set. The row is inserted in the row set at the position specified by the rownum parameter. If a row with that index already exists, it is moved further down in the row set and can be indexed with rownum + 1. Rows can be inserted with index values of 1 to rowset.Size + 1. The new row is created using a list of values or by copying values from a DJRecord object.
Syntax
rowset.Insert(rownum, record)
'OR
rowset.Insert(rownum, values)
Parameters
 
Type
Required
Description
DJRowSet
Yes
Reference to the DJRowSet object that is the subject of the property or method invocation.
Integer
Yes
Row index for where the row is to be inserted.
DJRecord
Yes
Reference to the DJRecord used to insert a new row in the row set.
Variant
Yes
Comma-delimited list of values used as field values for a new row in the row set.
Exceptions
The Insert method may return the following exceptions if there is an error at run time:
Exception
Description
ERR_TYPEMISMATCH
Returned if any invalid parameters are passed to the method.
Example
'The following example creates a new DJRowSet object and inserts a row at the beginning of the row set:
Dim rs As DJRowSet
Set rs = New DJRowSet
'Insert a row with two text strings and one integer as the first row:
rs.Insert(1, "First value", "Second Value", 3)
Operators
 
Operator
Type
Description
New Operator
DJRowSet
Create a new object.
New Operator
The New operator creates a new instance of a DJRowSet object. The operator returns a reference to the new object. Typically, this reference is assigned to an object variable that has been declared with a compatible type. The assignment is done using the Set statement.
Syntax
New DJRowSet
Example
'The following example creates a new row set and adds a row of data to it:
Public rs As DJRowSet
Set rs = New DJRowSet
'Append some data
rs.Append(1, 2, 3, 4, 5)
Last modified date: 10/22/2024