SclGetIterator
Overview
This command obtains an iterator that can be used for iterating over the rows, using SclIterateNext, to work with the rows that satisfy the constraints for an SclQuery operation.
Synopsis
$QueryHandle SclGetIterator IteratorHandle
Description
Create an iterator for the rows returned by the query.
Arguments
- QueryHandle
- IteratorHandle
The variable must contain a valid query handle.
Passed by reference. The variable to which the iterator handle will be assigned.
Examples
#
# Get the handle to an existing database and query the collar table
# displaying hole ID and max depth for each hole
#
if {[sclDatabases SclCountItems] < 1} {
error "No databases are connected"
}
sclDatabases SclGetItem DatabaseHandle 0
#
# create a query to iterate over all holes in the collar table
#
$DatabaseHandle SclQuery QueryHandle "collar"
$QueryHandle SclQueryColumn "hole_id" "max_depth"
$QueryHandle SclProcess
$QueryHandle SclGetIterator QueryIterator
while {[$QueryIterator SclIterateNext RowHandle] == $SCL_TRUE} {
set hole_id [$RowHandle SclGetValueByName "hole_id"]
set max_depth [$RowHandle SclGetValueByName "max_depth"]
puts "Hole ID=$hole_id, max_depth=$max_depth"
}
SclDestroy QueryHandle
|