• Welcome, Guest. Please login.
 
May 26, 2019, 01:50:28 pm

News:

Welcome to the SQLitening support forums!


how to get relative position

Started by G, January 15, 2009, 10:43:59 am

Previous topic - Next topic

G

I'm looking for the best way to size and position a scrollbar for a virtual listview. Do I have to implement my own record counter (via trigger or other method)?
Second I need to know the relative position within the table for the current index in use to calculate the position for the scrollbar.

Any hint about the way to go would be really great.

Fred Meier

If size of record set is not HUGE then slSelAry would work.

G

Thanks for the hint and yes, that should be the way to go for small or medium table. If you have to deal with up to a million records slSelAry I would be happy to find a more optimized solution.

Paul Squires

I think that you would need to use COUNT() in your query. If you have millions of records then I expect that it may be more efficient to maintain the record count in a separate table/field and update it via a trigger. Once you know how many records there are then positioning your relative scrollbar position should be easy because you would set your scrollbar's min and max values based on 1 (min) and record count (max). The recordsets are forward only cursors so you should always know how far into a recordset you are.

G

to maintain the counter in a separat record should result in a very small performace hit, I will give it a try.
even with foreward only cursors how do I get the relative position within the complete table if I start with a record where the field amount is greater than "x"? This record position can be anywhere within the table given the field amount as active index.

Fredrick Ughimi

Hello,

Is it possible to get the relative position of a record using something like?


  slSEL "SELECT COUNT(*) As RowCount FROM tblName WHERE BatchNo = '" + sBatchNo + "' AND CourseCode = '" + sCourseCode + "'"


Best regards.
Fredrick O. Ughimi

fughimi@yahoo.com
- Freedom lies in being bold -- Robert Frost, Poet

cj

Relative position in the table can be anywhere so scanning without an index and using LIMIT to exit?)
Relative position in  recordset  is the (line number or element number) of total lines.

Fredrick Ughimi

CJ,

Quote
Relative position in the table can be anywhere so scanning without an index and using LIMIT to exit?)


The snippet I posted isn't an attempt to write the code. In English, I met 'relative position of a record in a recordset'

I was thinking of how to retrieve the relative position number and also thinking, if rowid would give the relative position number of a record in a recordset.
Fredrick O. Ughimi

fughimi@yahoo.com
- Freedom lies in being bold -- Robert Frost, Poet

cj

June 01, 2018, 03:32:01 pm #8 Last Edit: June 01, 2018, 03:34:53 pm by cj
RowId could be anything in a recordset

1. The sArray() element number if using slSelAry sql, sArray()
2. The counter if using a DO WHILE slGetRow:INCR counter:LOOP