This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Oracle/OAS and the fly likes how to insert null values into table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "how to insert null values into table" Watch "how to insert null values into table" New topic
Author

how to insert null values into table

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
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

Joined: Oct 13, 2005
Posts: 38025
    
  22
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

Joined: Dec 21, 2006
Posts: 197
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

Joined: Oct 11, 2000
Posts: 1121

Reshma,
This is just a guess.
What about trying "PreparedStatement" and using its "setNull()" method?

Good Luck,
Avi.
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
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

Joined: Oct 11, 2000
Posts: 1121

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to insert null values into table
 
Similar Threads
how to insert values into enum fields in mysql
NULL value
insert statement
SQL syntax error
Data Conversion Process