db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@gmail.com>
Subject Re: obtaining a column value from a subset of a table
Date Sun, 16 Dec 2018 17:43:00 GMT
It's hard to say without seeing your code. Does some pattern like the 
following work for you:

     try (Connection conn = getConnection())

     {

       try (PreparedStatement ps = conn.prepareStatement(selectStatement))

       {

         try (ResultSet rs = ps.executeQuery())

         {

           while (rs.next())

           {

             int desiredColumn = rs.getInt(desiredColumnName);

             doSomethingWithThis(desiredColumn);

           }

         }

       }

     }


Hope this helps,
-Rick

On 12/15/18 1:29 PM, Bob M wrote:
> Hi
>
> I have a table with x records
> I am able to create a result set which is a subset of the records in the
> table and includes all columns
>
> I then wish to loop through each record in the subset and obtain the value
> from a certain column
>
> I try something like
>
> obtained_value = result;
>
> where result is a column in the table but I am not getting the value from
> that column
>
> what am I missing?
>
> Bob M
>
>
>
> --
> Sent from: http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html
>


Mime
View raw message