Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7807673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:55:34+00:00 2026-06-02T02:55:34+00:00

I am trying to obtain a float value from my Database The following checks

  • 0

I am trying to obtain a float value from my Database

The following checks if its null else returns 1; (works if null in DB but errors if a float)

month =  row.getString(39) != null ? row.getFloat(39): 1;

On the other hand, the following gets float directly. (works if float in DB but errors if null)

float test = row.getFloat(39);

How would I go about obtaining a float from the DB, and in the case of a null, return a default value. I cant get it in either format as it causes errors when in a diff format.

Preferably without changing the SQL statement. As since there are 45 variables, it would get far too big, messy and unmanageable. I havent looked into it, but I assume with SQL I can do some kind of IFNULL(field,default). Or maybe this is the best way… Although Id probably need AS field on the end too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:55:36+00:00Added an answer on June 2, 2026 at 2:55 am

    The following seems to work for any data type. Using getObject and checking if it is null. Even in the case of floats, where != null would otherwise be invalid comparison.

    month =  row.getObject(39) != null ? row.getFloat(39): 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to obtain the minimum value from a worksheet however when I
I am trying to obtain the value part of this syntax: [name:value] I got
I am trying to obtain the ip address from a text file so when
I'm trying to obtain the n-th elements from a list of tuples. I have
For a given SQL stored proc or function, I'm trying to obtain its input
I'm trying to obtain the price from a field called DiscountMarkupPriceRate1 on my second
I am trying to obtain and transfer information from a HTML web form (through
I'm trying to obtain the keywords from an HTML page that I'm scraping with
I am trying to obtain a variable from a different file type and import
I am currently trying to obtain the alpha value of a pixel in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.