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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use index file from one table for another table-diff is name else same

Status
Not open for further replies.

kenndot

Programmer
May 15, 2001
316
US
HI All,

I have a "best practices" question, looking for not necessarily code, but english on "how to" do the following... ( a little explanation first)

I have a big production table that I hit on a nitely basis to perform calculations and a variety of things. I am using a subset of this table (a several others in the same way) and using the SUBSTR( SYS(2015),3) function to get myself a unique name. This is the new name of the table now. The true name is PROFHDR for instance and now in the code I use select (profhdr) instead of select profhdr - I am storing the unique name in var named PROFHDR and using that throughout rather than using the production table

here's my question... there's also an index file for that table that I want the subset to use. maybe i'm thinking way too much into it and not seeing the answer, that very possibly could be, but what I would like is to use the production index file with the subset

can i copy the index file, rename it to the unique name .cdx? i just wanted to hear if there should be any problem in doing this? the indexes are too many and would take way too long to recreate so that's out, is this doable?
 
"Can I copy the index file, rename it to the unique name .cdx?"

No. Index file contents are directly related to records within the associated table.

I assume that your new table would not have the full recordset of the original table so it would not work.

You say that there are too many indicies to re-create them all on the new table(s), but have you considered doing it programatically with the TAGCOUNT(), TAG() and SYS(14) commands?

And, perhaps, after close scrutiny, you might not need ALL of the indicies on the new table(s).

Good Luck,
JRB-Bldr
 
Or you could leave the original file and index intact and do your calculations on the subset using SEEK, LOCATE, SCAN WHILE, and so on.
Another possibility would be to use COPY TO (PROFHDR) FOR SomeCondition WITH CDX.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
actually, it did work. I take a small subset of a table, rename it, then copied over the index file and renamed that and it openened fine and I was able to use the indexes and everything. Problem is, however that it takes some time because the files are big and I'm not sure that I want to do that every time the program runs so I am looking into any other possibilities so I will try what you've all mentioned here, too.

thanks!
 
here's an even better way, though

I open the original table
copy structure with production
insert into thetable SELECT blah from blah where blah

fast and efficient

thank you for your suggestions
 
... it openened fine and I was able to use the indexes and everything...

I would stay away from that if I were you. Since the index is not in sych with the table, you will receive errors. One of the first that comes to mind is Record is out of range. Another is Index does not match table. Recreate
You're playing with fire by simply copying that index file.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top