• 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
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

how to insert null values into table

 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi flocks,

i want to insert null values into table(i.e:suppose i am inserting 4 fields i that 2 fields is mandatory and rest of the fields is optional, in that optionsl places i want to insert null values one is string and second is long values), when i am trying this i am getting this error....

java.sql.SQLException: ORA-00936: missing expression

Thanks.
 
Marshal
Posts: 80749
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would that work?

I presume the other two columns (they're not called fields in SQL) are NOT labelled "not null?"
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am inserting this values from UI, in Page i am filling values(mandatory fields fields and i don't want to rest of optional fields in that place i want to insert null values automatically).whatever you wrote that query will work fine for two fields.

thanks
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reshma,
This is just a guess.
What about trying "PreparedStatement" and using its "setNull()" method?

Good Luck,
Avi.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in your data base use the default clause to set your values to null on the optional fields.

default value null
 
Avi Abrami
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
You said:


use the default clause to set your values to null


The default value is null, anyway.
You use the "default" clause if you want a column to receive a value other than null when inserting a row into a table and not specifying a value for that column.
Or am I mistaken?

Good Luck,
Avi.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic