[V4RB] updating records ... where am i going wrong?

Pedro fp lists at pedro.Net.au
Tue May 13 03:39:49 CDT 2003


G'day Folks

My moon table database has a field duration which is the difference in 
new moon time between the current & next moon phase. An important note 
is that the date & time data is as Julian Date Time numbers which are 
doubles that encapsulate both date & time for a given moment which 
means that time differences can be calculated by simple decimal 
subtraction. In my source data file the durations values are faulty so 
I added this method called after import ...

   dim i As integer, c As vCursor, b As boolean, nNew, nCur As double
   dim newPhase, newDuration As vDouble

   c = mDatabase.SQLselect( "SELECT phase1, duration FROM moon ORDER BY 
phase1" ) ' WHERE RecID > 0

   if c.recordCount > 0 then
     ' Assign cursor fields to variables.
     newPhase = c.doubleField( "phase1" )
     newDuration = c.doubleField( "duration" )

     for i = 1 to ( c.recordCount - 1 )
       c.currentPosition = i + 1 ' Go to the record ahead.
       nNew = newPhase.value ' Get the next new moon.
       c.currentPosition = i ' Go back to the current record.
       nCur = newPhase.value ' Get the current new moon.
       writeLog "nNew = " + str( nNew ) + ", nCur = " + str( nCur ) + ", 
duration = " + str( nNew - nCur )
       newDuration.value = nNew - nCur ' Set duration as the difference.
     next

     b = c.updateAll

     mDatabase.baseObject( "moon" ).flush
   else
     msgBox "Failed to get cursor for updating."
   end if

The writeLog line shows me that the differences are being calculated 
but when the data loads to my listbox all the differences are zero. Any 
clues as to what I'm doing wrong?

Cheers, Pedro :-)

Web: <http://www.pedro.net.au>                    PGP Key ID: 387CD96F
Instant messaging...  AIM: bandidoOfOz  ICQ: 27671678  Jabber: pedrofp
                       MSN: mail at pedro.net.au           Yahoo: pedro_fp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"What difference does it make to the dead, the orphans, and the
homeless, whether the mad destruction is brought under the name
of totalitarianism or the holy name of liberty and democracy?"
                                            M K (Mahatma) Gandhi





More information about the Valentina mailing list