aspose file tools*
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
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: 38363
    
  23
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: 1125

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: 1125

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.
 
 
subject: how to insert null values into table