Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> ResultSet getXXXX Behavior

ResultSet getXXXX Behavior

From: JV <jvirgil_at_optonline.net>
Date: Fri, 29 Oct 1999 04:14:15 GMT
Message-ID: <ra9S3.2116$Hc.6671555@news.optonline.net>


We are not sure if this is the correct behavior for a result set.



public void testAlias( com.gtms.securities.SecurityMasterImpl bo )
{

String sedol;
String desc;
String ctyCode;
String currCode;

try
{

// Create and execute the SQL statement. Statement statement = _conn.createStatement(); java.sql.ResultSet rs = statement.executeQuery (“SELECT

  sm1.sedol s,
  sm1.description d,
  sm2.ctycode c,
  sm2.currcode cc

FROM securitymaster sm1, securitymaster sm2 WHERE sm1.id = 89
AND sm1.id = sm2.id” );
if ( rs.next() )
{

sedol = rs.getString( “s” );
System.out.println(“********** SEDOL = “ + sedol); desc = rs.getString( “d” );
System.out.println(“********** DESCRIPTION = “ + desc); currCode = rs.getString( “cc” );
System.out.println(“********** CURRCODE = “ + currCode); ctyCode = rs.getString( “c” );
System.out.println(“********** CTYCODE = “ + ctyCode); }
statement.close();
statement = null;
}
catch( SQLException sqle )
{

System.out.println( sqle );
}
}

This is the result:

Oct 28 12:06:15 1999: ********** SEDOL = 4019950 Oct 28 12:06:15 1999: ********** DESCRIPTION = ALLGEMEINE BAUGE S TAMM AUSH 1000
Oct 28 12:06:15 1999: ********** CURRCODE = EUR Oct 28 12:06:15 1999: java.sql.SQLException: [Oracle][ODBC]Invalid column number <3>.

It seems that if the rs.getXXX( “whatever” ) are not in the same order as the columns in the select statement it won’t work. After experimenting it seems that once you have retrieved the value from a specific column, you can ’t go backwards. It behaves the same way if we use column index instead of column name on the getXXXX. If the columns are accessed in order, everything works.

Are we missing something or do the getXXXs need to be in the same order as the columns in order to retreive data out of the result set? Received on Thu Oct 28 1999 - 23:14:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US