A Possoble Bug in DCOracle2?

DeepBlue DeepBlue at DeepBlue.org
Sat Oct 6 17:17:04 EDT 2001


Have anyone run into the following problem:
import DCOracle2
db=DCOracle2.Connect(SomeconnectionString)  # use some database
c=db.cursor()
c.execute('select * from SomeTable') #use your favourite sql statement
r=c.fetchone()
list=r[0]
while r:
  r=c.fetchone()
  list.append(r[0])

we get an error that index is out of range.  The reason is that a null
element is being appended to list and an error is produced.

The following works fine:
db=DCOracle2.Connect(SomeconnectionString)  # use some database
c=db.cursor()
c.execute('select * from SomeTable')  #use your favourite sql statement
r=c.fetchone()
list=r[0]
while r:
  r=c.fetchone()
  if r != None:
    list.append(r[0])

which means that in this case where r = None, nothing is appended to the
list.
Now try this:  Assume that we know that the result of the sql will produce
three rows:
db=DCOracle2.Connect(SomeconnectionString)  # use some database
c=db.cursor()
c.execute('select * from SomeTable') #use your favourite sql statement
r=c.fetchone()
print r
while r:
  r=c.fetchone()
  print r

What is printed is not three rows, but FOUR rows.  the fourth one is None.
So, an extra row is being produced, with the fourth one being None.
Is this a bug?
DeepBlue









More information about the Python-list mailing list