Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to insert null values into table

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50217
79
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reshma,
This is just a guess.
What about trying "PreparedStatement" and using its "setNull()" method?

Good Luck,
Avi.
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • 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: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic