Progress
SQL-92
Guide and Reference


SQLCursor.getValue

Assigns a single value from a SQL result set to a procedure variable. The single field value is the result of an SQL query or the result from another stored procedure.

Format

public Object getValue( int fieldNum, short fieldType )

Returns

Object

Parameters
fieldNum

An integer that specifies the position of the field to retrieve from the fetched record.

fieldType

A short integer that specifies the data type of the parameter. The allowable defined values for fieldType are listed in Table 6–3, grouped by category of data type.

Table 6–3: Allowable Values for fieldType in getValue 
Character
Exact Numeric
Approximate Numeric
Date-time
Bit String
CHAR
INTEGER
REAL
DATE
BIT
CHARACTER
SMALLINT
FLOAT
TIME
BINARY
VARCHAR
TINYINT
DOUBLE
TIMESTAMP
VARBINARY
NUMERIC
LVARBINARY
DECIMAL

Throws

DhSQLException

NOTES

EXAMPLE

This example illustrates testing for null and invoking the Java getValue method:

Integer  pvar_int = new Integer(0);
String   pvar_str = new String();
SQLCursor select_t1 = new SQLCursor
     ("select int_col, char_col from T1");
 
Select_t1.open();
Select_t1.fetch();
 
while(select_t1.found())
{
     // Assign values from the current row of the SQL result set
     // to the procedure variables. First check whether 
     // the values fetched are null. If null then explicitly
     // set the procedure variables to null.
 
     if ((select_t1.wasNULL(1)) == true)
          pvar_int = null;
     else
          pvar_int = (Integer)select_t1.getValue(1, INTEGER);
     if ((select_t1.wasNULL(2)) == true)
          pvar_str = null;
     else
          pvar_str = (String)select_t1.getValue(1, CHAR);
} 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095