Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bi-Dimensional Arrays and Re-sorting - Serious Problem

Status
Not open for further replies.

Gaby10414

Programmer
Jan 10, 2005
3
US
Hello,

I am ecountering a serious error that I believe is beyond the capabilities of classic ASP. I hope someone has a solution and can help me. I do not want to have to re-code my script in a different language.

I'm using a 3rd party search engine (not MS Full-Text) to perform full text searches against a pretty big MS-SQL database. The database contains many tables with the same structure (same columns). The problem IS NOT in the MS-SQL database, SQL programming, or the third party Search Engine. The problem is in the ASP code when manipulating the database results AFTER the engine successfully returns all database results to the ASP script after the query is done.

The third party search engine sends every record back to the ASP script with a RANK number. Every record returned in the recordset has an assigned rank number for ordering the results. Let's call this number RANK. When submitting a query I am using a While loop to retrieve results from multiple tables in the database for the same keyword query. Searching the multiple tables is done using a WHILE loop and seperate recordsets with all records having the RANK number are returned. There is NO UNION available. There is NO problems in the ASP up to this point.

Although I am searching multiple tables in the database the ASP script I am developing will display all results in ONE list and ordered by the RANK number.

I created a two-dimensional array to keep a pair of values retrieved from the While loop. The pair was 'RANK-INDEX'. After that i applied the QuickSort algorithm to re-order original results by 'RANK'.

The problem is the following: Declaring a two-dimensional array by setting a precise range of values for each dimension either with Dim or ReDim leads to two options:
either the results retrieved from the database are over the upper bound of the array, or, if we assign numbers that are too big for these dimensions, the QuickSort algorithm returns the 'out of stack' error.

Is there a way to dynamically build such a two dimensional array (something similar with Split function for one dimension arrays)? Thank you.
 
Not sure that I have an answer for you, but some relevant code may allow someone to be better able to help.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Using classes and class references you could easily create some sort of heap array, with each heap being a specific rank. Or if your kinda bored you could search through the forums for my posts on binary tree objects. Basically with a binary tree all you would have to do is modify it to decide left/right branch based on the RANK field and start dropping data in it, then just pull it out in order.

If your already getting stack errors you may want to go with some sort of stack/heap array method. This will limit the stack size at any given point instead of attempting to act on every item. This could be as basic as an array of link list nodes with functions to give them values and functions to get their (and their childrens) values. Dump values in each index based on their rank and all you have to do to get them out in order is to loop from highest to lowest index.

<opinion>
(for the record):
There is NO UNION available[/quote
seriously contradicts:
The problem IS NOT in the MS-SQL database, SQL programming, or the third party Search Engine.

You should be able to solve all of this with a single query and set of JOIN's. The inability to do so is a failing in either the database design or SQL calls. Manipulating tabled data is what databases do. Forcing that onto the client-side (app is client, db is server) is a failure in the server/db/communications component.</optinion>

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top