float TotalSale = 0f;
while (Rs.next()) {
                    TotalSale = Rs.getFloat("n_totalprice");
                    System.out.println(TotalSale);// no error
                     }
 System.out.println(TotalSale);

I would like to point that float is not a good type for this kind of
calculation because of rounding errors.



On Wed, Jun 16, 2010 at 4:50 PM, shainnif ismail <shain...@gmail.com> wrote:

> have you tried to use using the column index
>
>
>
> On 15 June 2010 10:27, marc <pavi...@gmail.com> wrote:
>
>> Hi all
>>
>> I am getting an error on the following code when I want to access the
>> variable "TotalSale" out side the loop.
>>
>> ***************************************************************************
>>  ResultSet Rs = sta.executeQuery("SELECT n_totalprice,id FROM orders
>> WHERE  ID = IDENT_CURRENT('orders')");
>>
>>                     while (Rs.next()) {
>>                     float TotalSale = Rs.getFloat("n_totalprice");
>>                     System.out.println(TotalSale);// no error
>>                      }
>>  System.out.println(TotalSale);//Error TotalSale cannot be resolved
>>
>> ***************************************************************************
>>
>> I am getting single value from the databse so i also tried with the
>> following code but still the result is same.
>>
>>
>> ***************************************************************************
>>  if (Rs.next()){float TotalSale = Rs.getFloat("n_totalprice");}
>>
>> ***************************************************************************
>>
>> Can any body please help me.Thank you in advance
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "The Java Posse" group.
>> To post to this group, send email to javapo...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> javaposse+unsubscr...@googlegroups.com<javaposse%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/javaposse?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to javapo...@googlegroups.com.
> To unsubscribe from this group, send email to
> javaposse+unsubscr...@googlegroups.com<javaposse%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to