Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Paradox > Re: Query direc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 16 Topic 1290 of 1417
Post > Topic >>

Re: Query directly from secondary index

by "Jim Moseley" <jmose@[EMAIL PROTECTED] > Oct 18, 2007 at 04:46 PM

If anyone is interested, here's the library routine I wrote to determine
which
file could be used for a query - X01..XG9 if 2nd index, DB otherwise:

;---- start ------
var
   saveTableExtAR	array[] string	   
   saveTableExtDyn dynArray[] string
endVar


method getQueryTableExt(var tcIn tcursor, curTab string, curField string)
string
var
	idxTC,
	tc tcursor
endVar

curExt 	= "db"

while true
if saveTableExtAR.size() > 0 then
   if saveTableExtAR.contains(curTab) then  ; only first time
   	quitloop
   endif
endif

iTab = ":priv:queryExt.db"
ok = tcIn.isAssigned()
if ok then
	ok = tc.attach(tcIn)
else
	ok = tc.open(curTab)
endif
if ok then
	ok = tc.enumIndexStruct(iTab)
endif
if ok then
	ok = idxTC.open(iTab)
endif
if not ok then
	errorShow()
	return(curExt)
endif

extStr = ""
addIt = true
scan idxTC :
	if not idxTC.iIndexID.isBlank() then
   	curIdxStr = toHex(idxTC.iIndexID)
      maxI = curIdxStr.size()
      if maxI > 3 then
      	if curIdxStr.subStr(maxI - 2,1) <> "0" then
         	extStr = "XG" + curIdxStr.subStr(maxI,1)		; 256: 0x00000100 =
XG0
         else
         	extStr = "X" + curIdxStr.subStr(maxI-1,2)		; 1: 0x00000001 = X01
         endif
      endif
   endif
	curSlot = curTab + ":" + upper(idxTC.FieldName)
   if extStr <> "" then
	   saveTableExtDyn[curSlot] = extStr
      if addIt then
    		saveTableExtAR.addLast(curTab)
         addIt = false
      endif
   endif
endScan
quitloop
endWhile

if saveTableExtAR.contains(curTab) then
   curSlot = curTab + ":" + curField
   if saveTableExtDyn.contains(curSlot) then
   	curExt = saveTableExtDyn[curSlot]
   endif
endif

return(curExt)
endMethod
;------- end -------



The calling form's code can be this easy, though if you have multiple
columns
or tables it gets more complicated:

Uses ObjectPal
   getQueryTableExt(var tc tcursor, curTab string, curField string) string
endUses

;...
masterTab = "Customer"
if tc.dmattach("MASTER") then
   tabExt = lUtil.getQueryTableExt(tc, masterTab, srchFld)
   if tabExt <> "" then
   	masterTab = masterTab + "." + tabExt
   endif
endif

qry1 = "Query  "
qry1 = qry1 + "\n\n" + masterTab + " | CustNo | "
qry1 = qry1 + "\n" + " | Check > 0 |\n\n"

qry1 = qry1 + masterTab + " | " + srchFld + " | "
qry1 = qry1 + "\n | " + srchFor + " |"
qry1 = qry1 + "\n\n" +  "EndQuery  "

ok = q.readFromString(qry1)
if ok then
   ok = qrySave.executeQBE()
endif
if not ok then
   errorShow()
endif
 




 16 Posts in Topic:
Query directly from secondary index
"Jim Moseley" &  2007-10-18 02:03:52 
Re: Query directly from secondary index
"Anders Jonsson"  2007-10-18 08:40:54 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 08:16:21 
Re: Query directly from secondary index
"Anders Jonsson"  2007-10-18 17:20:39 
Re: Query directly from secondary index
"Tony McGuire"   2007-10-18 09:53:54 
Re: Query directly from secondary index
"Anders Jonsson"  2007-10-18 19:05:42 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 13:53:37 
Re: Query directly from secondary index
"Rick Rans" <  2007-10-18 14:44:50 
Re: Query directly from secondary index
"Steven Green"   2007-10-18 05:47:56 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 08:05:38 
Re: Query directly from secondary index
"Steven Green"   2007-10-18 09:15:42 
Re: Query directly from secondary index
"Bertil Isberg"  2007-10-18 21:26:37 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 16:36:19 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 16:46:26 
Re: Query directly from secondary index
"Jim Moseley" &  2007-10-18 17:17:11 
Re: Query directly from secondary index
"Bertil Isberg"  2007-10-19 18:55:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 17:44:05 CDT 2008.