Kurt Welgehausen wrote:

proc lpartition {recsize data} {
 set ret {}
 set datalen [llength $data]
 for {set i 0; set j [expr {$recsize-1}]} \
     {$i < $datalen} {incr i $recsize; incr j $recsize} {
   lappend ret [lrange $data $i $j]
 }
 set ret}

So is there another way to determine the number of columns/or results of a query to calculate recsize?
A query can be quite complicate like combined SELECTs or something like {SELECT*,rowid from...}


db eval {SELECT*,rowid from t1} data {set columns $data(*); lappend records ....}]
set recsize [llength ${columns}]
set recordslist [lpartition ${recsize} ${records}]


This still requires the eval script and has the drawback duplicating the used memory.

There seems to be only two simple and fast solutions for me.
- First one is creating another db subcommand (e.g.: db evallist ...}
- Second one would be easier (but slower?) creating another element (a pedant to data(*)) holding exactly one row of the result array


 data(*)            = a b rowid
 data(a)            = 3
 data(b)            = howdy!
 data(rowid)        = 3
 data(typeof:a)     = text
 data(typeof:b)     = text
 data(typeof:rowid) = INTEGER
proposed:
 data(_)  = {3 howdy! 3}


TIA

Stefan

Reply via email to