Hi everyone, I was wondering if anyone could lend me some help on a problem I am having.
Currently my asp page reads and interacts with my oracle database just fine, however i'm having a problem with either my if statement cause it's putting out wrong values or perhaps it is what i put in my if statement.
About the code i'm writing, in the database every element has a primary key (as it should) that is simply an interger from 1 to whatever. I want users to be able to remove rows from the database, which would leave "gaps" in the primary key, for example:
PID (stands for Primary ID)
1
2
3
4
6
7
...
if the user removed row 5. Now, my asp code will read the data in from an oracle databse, and SHOULD find the gap, and assign the missing number automatically when the user submits a new row.
so here is the problem im having:
newnum=0
dbnum=0
old=0
Do While(OraDynaset.EOF = FALSE)
old=OraDynaset.Fields("PID")
OraDynaset.MoveNext
newnum=OraDynaset.Fields("PID")
dbnum=newnum 'what will be the "gap"
'if no gap will be last num +1
if newnum<>old+1 then
dbnum=old
exit do
end if
Loop
Set OraSession = Nothing
-----------------------------------
then i increment dbnum+1 after and add some formatting and blah blah... ANYWAYS
my main problem is my if statement really does not work. I've checked the values all my variables output with a simple response.write(....) and I always get that
newnum=2
old =1
old+1 =2
however,
newnum<>old+1 results in TRUE when it should be FALSE..
also incase you're wondering
newnum=old+1 results in FALSE when it should be TRUE..
if anyone has any idea why in the hell this is happening i would be incredible grateful. One thing that came to my mind was assigning the OraDynaset.Fields("PID").
Also it may seem like the logical thing to do would be to simply use an = instead of <> since it seems reversed, but this doesn't work either.
Currently my asp page reads and interacts with my oracle database just fine, however i'm having a problem with either my if statement cause it's putting out wrong values or perhaps it is what i put in my if statement.
About the code i'm writing, in the database every element has a primary key (as it should) that is simply an interger from 1 to whatever. I want users to be able to remove rows from the database, which would leave "gaps" in the primary key, for example:
PID (stands for Primary ID)
1
2
3
4
6
7
...
if the user removed row 5. Now, my asp code will read the data in from an oracle databse, and SHOULD find the gap, and assign the missing number automatically when the user submits a new row.
so here is the problem im having:
newnum=0
dbnum=0
old=0
Do While(OraDynaset.EOF = FALSE)
old=OraDynaset.Fields("PID")
OraDynaset.MoveNext
newnum=OraDynaset.Fields("PID")
dbnum=newnum 'what will be the "gap"
'if no gap will be last num +1
if newnum<>old+1 then
dbnum=old
exit do
end if
Loop
Set OraSession = Nothing
-----------------------------------
then i increment dbnum+1 after and add some formatting and blah blah... ANYWAYS
my main problem is my if statement really does not work. I've checked the values all my variables output with a simple response.write(....) and I always get that
newnum=2
old =1
old+1 =2
however,
newnum<>old+1 results in TRUE when it should be FALSE..
also incase you're wondering
newnum=old+1 results in FALSE when it should be TRUE..
if anyone has any idea why in the hell this is happening i would be incredible grateful. One thing that came to my mind was assigning the OraDynaset.Fields("PID").
Also it may seem like the logical thing to do would be to simply use an = instead of <> since it seems reversed, but this doesn't work either.