getCol Method

Class: ResultSet

Description

This method returns the column value from the results row in the results set object. You can specify either the column number or the alpha identifier for the column to retrieve the results.

Syntax

objectName.getCol(Number columnNumber)

objectName.getCol(String columnName)

Parameters

columnNumber

The number identifying the table.column from which to retrieve data.

columnName

The alpha identifier for the table.column from which to retrieve data.

The columnName can only be used in the subroutine where the ResultSet is instantiated, and only if the selectlist is supplied as a literal in the Db.select method.

Returns

A String.

When Became Available

Profile v6.0

Example #1 -- Using Column Numbers

type String ACN,NAM,TAXID

type ResultSet rs = Db.select("ACN,NAM,TAXID","CIF")

while rs.next()  do {

       set ACN = rs.getCol(1)

       set NAM = rs.getCol(2)

       set TAXID = rs.getCol(3)

       }

Example #2 – Using Column Names

type String ACN,NAM,TAXID

type ResultSet rs = Db.select(“ACN,NAM,TAXID”,”CIF”)

while rs.next() do {

       set ACN = rs.getCol(“acn”)

       set NAM = rs.getCol(“nam”)

       set TAXID = rs.getCol(“taxid”)

       }