Solved

oracle null record

Posted on 2000-05-08
8
231 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 86
How to display the different types of results from a Query 2 45
Using querystring in a hyperlink 3 51
Call a function within the ASP code 4 12
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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