Link to home
Start Free TrialLog in
Avatar of mikeandbee
mikeandbee

asked on

hash tables in ASP page

Hi,
Can i use hash tables (lookup) within an asp page?

I have a statis table in my db which has three rows describing a certain event. But it means my sql queries will have to always join this table and make the sql much more arduous. If i can use a lookup table however, I can simply reference the value of the three rows directly in the sql.
ie
select * from stat_table

Dim POS = 1
Dim DISt = 2
Dim TIME = 3

then in subsequent sql queries I can simply say WHERE stat_id = 1...

how do i use it in asp?
Avatar of andyclap
andyclap
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use the scripting dictionary object as a simple hash table.
However I'm not sure I folow what you're trying to do here:
You could do an initial query to look up your ids into a recordset and then use a seek to look up the text value. Or alternatively if your values are more or less sequential, you could use an array. One further method is to create a little activeX object in VB which can instantiate and return a new collection which can act as a very simple hash table.

Avatar of mikeandbee
mikeandbee

ASKER

hopw can i use the dictionary object to achieve this?
Well, the way I do is

set dic = CreateObject("Scripting.Dictionary")
dic("objectName") = objectName
dic("libraryid") = libraryid
sql = getObjectListSQL(dic)

then in  getobjectlistsql
<%
     function getObjectListSQL(dic)
          Dim objectName, libraryid
          dim Conn
          Set Conn = Server.CreateObject("ADODB.Connection")
          Conn.Open Session("Oracle_DSN"), Session("Oracle_Username"), Session("Oracle_Password")
          objectName = dic("objectName")
          libraryid = dic("libraryid")
          if(libraryid = "") then
               libraryid = "%"
          end if
          dim sql
          sql     = _
               " select " & _
               "     obj.n_id                    as objectid, " & _
               "     obj.c_name                    as objectName, " & _
               "     obj.c_type                    as objectType, " & _
               "     lib.n_id                    as libraryid, " & _
               "     lib.c_name                    as libraryName, " & _
               "     lve.c_version               as libraryVersion, " & _
               "     lve.d_released               as versionDate, " & _
               "     upper(obj.c_name) " & _
               " from " & _
               "     mrd_object obj, " & _
               "     mrd_object_instance oin, " & _
               "     mrd_library_version lve, " & _
               "     mrd_library lib " & _
               " where " & _
               "     upper(obj.c_name) like '" & ucase(objectName) & "%' AND " & _
               "     lib.n_id like '" & libraryid & "' AND " & _
               "     obj.n_id = oin.n_object_id AND " & _
               "     lib.n_id = oin.n_library_id AND " & _
               "     lve.n_library_id = lib.n_id AND " & _
               "     lve.c_version = oin.c_library_version AND " & _
               "     lve.d_released = (select max(a.d_released) from mrd_library_version a, mrd_object_instance b where a.n_library_id=b.n_library_id AND a.c_version=b.c_library_version AND b.n_object_id=obj.n_id)" & _
          conn.close
          set conn = nothing
          getObjectListSQL = sql

The objectname and libraryid are obtained from a previus page.

Let me know and in the meantime let me try to udnestand your other question
ASKER CERTIFIED SOLUTION
Avatar of jitganguly
jitganguly

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
regarding the last comment, how could i then use this in a sql query?
Please award/close or advise what else is needed.
Moondancer
Community Support Moderator @ Experts Exchange
This question appears to have been abandoned, all your open questions are posted below.
Your options are:
1.  Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3.  Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4.  Delete the question. Again, you must tell the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below, include the question QID/link.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this Help Desk link for Member Guidelines, Member Agreement and the Question/Answer process:  Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues.
https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:
 
Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
 
Thank you everyone.

Open Qs:
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11677198
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20136244
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20138104
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20139384
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20141051
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20141266
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20147138
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20175597
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11188236

Moondancer
Moderator @ Experts Exchange
 
P.S.  For year 2000 question, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

Prior request ignored, finalized.