Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Null values in int

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
I have a req in a case where two tables are lined in which the foreign key is an int. and the foreign key is not mandaory.
So i want to make the value of int as null.
I also tried with Integer class.
Can u throw some light on this.

Regards,
Pradeep

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are we talking database-tabels here?
Is it a insert or read you are trying to do?
The easiest way to get a null, is creating an sql-query, and just omitting the value that should be null, or setting it to null. That should be no problem as the sql-queries are strings.
As for representation in the program, I usually try to know the limit of the value used. Since it's a foreign key, it's linked to a primary key of some othar table. These keys usually start at 0 or 1, so by using a nullValue-operator on the select, you can convert the null value to a negative, fixed value, representing null inside your app.
/Mike
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic