Solved

oracle null record

Posted on 2000-05-08
8
226 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now