FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SQL queries. Positioning over a specific record
Posts: 29
Joined: Fri Jan 18, 2008 03:48 PM
SQL queries. Positioning over a specific record
Posted: Wed Apr 30, 2008 03:53 PM

Hi guys

I wonder if is it possible set the table pointer into an specific record provided by a SQL ADS query

My problem is the following:

I have a SQL query with too many results. Then, I think in giving the users the abiliity of searching through this result set and positioning over the
selected record.

With no SQL queries, this job was simple, only changing the index with ordsetfocus and executing a dbseek. But with an alias which is a result of a query i don´t know the way for do it...

Executing sql queries, are generated some default indexes ??

Thank In advance

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
SQL queries. Positioning over a specific record
Posted: Wed Apr 30, 2008 08:53 PM

If you are referring to the result of an SQL query, then you mean a "cursor". ADS cursors can be treated just like any .dbf alias.

(alias)->( recno() )

will yield the record number where the file pointer is in the cursor.

I hope I answered the question.

Reinaldo.

Posts: 29
Joined: Fri Jan 18, 2008 03:48 PM
SQL queries. Positioning over a specific record
Posted: Wed Apr 30, 2008 09:37 PM

Thanks Reinaldo for your interest...

Yes, I´m using this results as an alias..

But... how can I execute any search in that alias (cursor)...ie: the alias has 3 fields: name, tel, id, and I want to permit the users search over any of these fields...If the user chooses id and searches "1059", the cursor must go to that record, a lo DBSEEK.

Can you understand my problem...

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
SQL queries. Positioning over a specific record
Posted: Wed Apr 30, 2008 10:03 PM

I think I understand.

You can create an index, or even a temp index and then:

(cCursor)->( dbseek( ) ).... As you would on a real table.

With ADS server creating an index should happen very fast.

That should work.

Another option is to load the data into an array (dbeval()) and then allow the user to sort the data by clicking on the column's header (aSort()). Then allow them to increment search using aScan().

The SQL statement could be ORDER BY... so a quick search is possible using a binary search on sorted data.

Hope this helps.

Reinaldo.

Posts: 29
Joined: Fri Jan 18, 2008 03:48 PM
SQL queries. Positioning over a specific record
Posted: Wed Apr 30, 2008 11:12 PM

Thanks mate...

Excuse my poor knowlegdment, but, how is created the temp index over the cursor.. For do it, isn´t necessary opening in exclusive mode ?

Can you post any example ?

Continue the discussion