Solved

oracle null record

Posted on 2000-05-08
8
233 Views
Last Modified: 2008-02-01
hi...
im working in asp on oracle database.
let's say im making select list box:

<select name="hour">
<option value="">choose hour</option>
<option value="0800">08:00</option>
<option value="0900">09:00</option>
</select>
<input type=submit...

in the next as page:
<%
hour=request.form("hour")
sql="insert into hours values('"&hours"',23,'user')"
%>
in this case the user CAN choose the first choice (<option value="">)-
which mean the database get "" as value.
how can i search for this record?
is this right?
sql="select * from hour where hour is NULL"
or maybe
sql="select * from hour where hour=""

thanx
eladr
p.s. : im on oracle db.


0
Comment
Question by:eladr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 2787662
it depend on how you insert the record.

first of all allow null fields in that col.

then either inset it as NULL (thas what i do) and serach for it as 'field Is Null'

or insert it as '' and serach for 'field = '''

both will work fine.

hope this helps

ohh

in your select box just put the value on the empty one to either value="NULL" or value = "". if you use value="NULL" rememebr not to wrap it in '' when inserting it as youll actuall insert the word NULL
0
 
LVL 2

Expert Comment

by:gaetansavoie
ID: 2788897
Yes this shoud work:

sql="select * from hour where hour is NULL"
0
 
LVL 11

Expert Comment

by:mouatts
ID: 2790584
For Oracle you should use

field IS NULL as it is optomises better than =''.

But I wouldn't use option value=NULL as someone is likely to come along and wrap it quotes (won't I makep :) )

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:eladr
ID: 2791372
so i understand that the query must be where
field is NULL .
but what should i put in the empty value option:
<option value=null...>
<option value=""l...>
??
elad
0
 
LVL 10

Expert Comment

by:makerp
ID: 2791699
hi mouatts.

you would never do such a thing :)

i think that for your solution the '' would be easier to implement than the NULL. just set the option value to "" and then one simple insert will cope with "" and hours...

INSERT iNTO blah1 (hours) VALUES('"&Request("hours")&"')

a select will also be simplyfied. a select box could be used to the same effect....

0
 
LVL 11

Accepted Solution

by:
mouatts earned 15 total points
ID: 2791759
eladr

use either "" or no value at all in the option tag

which will resolve to '' in an update ie set x='"&request("selectname")&"'...

but use IS NULL in a selection.

Steve
0
 
LVL 1

Author Comment

by:eladr
ID: 2791768
it was hard to choose the best answer.
mautas was the most complete.
thanks you all
happy independence day for israel !
0
 
LVL 10

Expert Comment

by:makerp
ID: 2791779
it will be easier to use "" as then your select box will not have to have NULL in which means you wont have to make sure you dont quote it up..

any way if you have inserted "" the field Is Not NUll :) so select where IS NULL will fail unless you enetred NULL.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question