Try OpenEdge Now
skip to main content
SQL Reference
JDBC Reference : Java Class Reference : SQLCursor : SQLCursor.getValue : Throws


*Before invoking getValue, you must test for the NULL condition by calling the SQLCursor.wasNULL method. If the value returned is NULL, you must explicitly set the target variable in the stored procedure to NULL.
*The getValue method returns a value from the result set identified by the number you specify in the fieldNum parameter. getValue returns the value as an object of the data type you specify in the fieldType parameter. Since getValue returns the result as an instance of class Object, you must explicitly cast your return value to the correct data type.
*If the returned value is of data type CHARACTER, then getValue returns a Java String Object. You must declare a procedure variable of type String and explicitly cast the value returned by getValue to type String.


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");;
{ // 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;
pvar_int = (Integer)select_t1.getValue(1, INTEGER);
if ((select_t1.wasNULL(2)) == true)
pvar_str = null;
pvar_str = (String)select_t1.getValue(1, CHAR);