Quantcast
Channel: GSAK Forum
Viewing all articles
Browse latest Browse all 75146

Copy Database Row Number to UserData Column by Lt.Ranger.Bob - 2013-07-27

$
0
0
QUOTE (hynr @ July 27, 2013 12:51 pm)
QUOTE (Lt.Ranger.Bob @ July 26, 2013 12:27 pm)
If anyone is interested here is the finished code as I put it together....
Two suggestions:

1. On my computer with a set of 25267 records that macro code takes 320 seconds; if you wrap it into a transaction then it takes about 20 seconds.

2. Note that the above code will probably not generate desired results on sets of more than 100 caches. My sense is that if others are using it, then perhaps that limitation is problematic. Here is an alternative:
GSK
Beginsub Name=CodeToTest
 $X = 1
 $_SQL="Select count(*) from Gridtemp"
 $digits=2+int(log(10,val(sqlite("sql",$_SQL))))
 Goto Position=Top
 $TransactionSituation=Intransaction()
 #IF a transaction is already active at this time, then do nothing, otherwise start a Transaction
 IF not($TransactionSituation)
   Transaction Action=Begin
 Endif
  While not($_EOL)
    $d_Userdata = Right("0000000000" + NumtoStr($X) + ".",$digits)
    $X = $X + 1
    Goto Position=Next
   EndWhile
 Transaction Action=End  #Commit the changes of the current transat
 IF $TransactionSituation
   #if a transaction was already active then restart a transaction
   Transaction Action=Begin
 Endif
Endsub

I am probably doing something wrong. I copied your code into a macro and have tested it a couple of times and it does not seem to do anything, or at least it has not created the numbers in the UserData column. I do see what you mean about my code and the long run time on larger databases. I tried it on a database that had over a 1000 waypoints and it did have a very long run time. I did not time it but it ran so long I was starting to think it was not doing anything when it finally finished.

Viewing all articles
Browse latest Browse all 75146

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>