SQL queries. Positioning over a specific record

SQL queries. Positioning over a specific record

Postby BenD » Wed Apr 30, 2008 3: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
BenD
 
Posts: 29
Joined: Fri Jan 18, 2008 3:48 pm

Postby reinaldocrespo » Wed Apr 30, 2008 8: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.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby BenD » Wed Apr 30, 2008 9: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...
BenD
 
Posts: 29
Joined: Fri Jan 18, 2008 3:48 pm

Postby reinaldocrespo » 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.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby BenD » 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 ?
BenD
 
Posts: 29
Joined: Fri Jan 18, 2008 3:48 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 48 guests