BBjAPI::createMemoryRecordSet

Description

In BBj 7.00 and higher, this method creates a record set in memory that behaves in the same way as an SQL record set. A memory record set allows the developer to create a record set from a string template and then populate that template with data as they see fit. 

One of the most common uses for memory record sets is in stored procedures because stored procedures often need to return an SQL result set to the client application. A memory record set gives the developer the ability to create a record set (that the SQL engine later converts to a result set), populate this record set with arbitrary data, and return the record set as the result of the stored procedure call.

Syntax

Return Value

Method

BBjRecordSet

createMemoryRecordSet(string stringTemplate)

Parameters

Variable

Description

stringTemplate

The string template that defines the field layout for records contained in the record set. The template follows standard string template syntax.

Return Value

Returns an in-memory BBjRecordSet object.

Remarks

None.

Example

rem ' createMemoryRecordSet sample

template$ = "ID:I(4),NAME:C(100* = 10)"

rem ' Create the RecordSet
RecordSet! = BBJAPI().createMemoryRecordSet(template$)

rem 'Add a record to the record set
Data! = RecordSet!.getEmptyRecordData()
Data!.setFieldValue("ID", "1")
Data!.setFieldValue("NAME", "John Doe")
RecordSet!.insert(Data!)

rem 'Add another record to the record set
Data! = RecordSet!.getEmptyRecordData()
Data!.setFieldValue("ID", "2")
Data!.setFieldValue("NAME", "Jane Smith")
RecordSet!.insert(Data!)

rem 'Move to the first record
RecordSet!.first()
Data! = RecordSet!.getCurrentRecordData()
print "The first record is:",'LF',Data!,

rem 'Move to the next record
RecordSet!.next()
Data! = RecordSet!.getCurrentRecordData()
print "The next record is:",'LF',Data!,
stop

See Also

BBjAPI

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.