eladr
asked on
oracle null record
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.
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.
Yes this shoud work:
sql="select * from hour where hour is NULL"
sql="select * from hour where hour is NULL"
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 :) )
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 :) )
ASKER
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
field is NULL .
but what should i put in the empty value option:
<option value=null...>
<option value=""l...>
??
elad
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....
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....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it was hard to choose the best answer.
mautas was the most complete.
thanks you all
happy independence day for israel !
mautas was the most complete.
thanks you all
happy independence day for israel !
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.
any way if you have inserted "" the field Is Not NUll :) so select where IS NULL will fail unless you enetred NULL.
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