• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

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
 
rubbery bacon. crispy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic