>Hi,
>
>Thanks for your responses. I discussed this problem with my manager also and he told me that there is no big differance between Primary and Candidate indexes.
>So, we decided to change Type from Primary to Candidate in our IndxDict table.
>
>And now I do this: (Right now I'm checking its functionality)
>
>SELECT IndxDict
> SCAN FOR Upper(Table)=Upper(lcTableName)
>
> lcCommand=;
> "INDEX ON AllTrim("+IndxExpr+") TAG Alltrim(" +TagName+ ")"+;
> IIF(Not Empty(Filter), " FOR Alltrim("+Filter+")","")+;
> IIF(UPPER(Type)="CANDIDATE"," CANDIDATE","")
> SELECT (lcTableName)
> &lcCommand
>
> SELECT IndxDict
> ENDSCAN
>
>
Nadya,
First, there are serious problems in how you're constructiong your index command; I'd try the following modifications:
lcCommand=;
"INDEX ON " + AllTrim(IndxExpr) + ;
" TAG " + Alltrim(TagName) + ;
IIF(Not Empty(Filter), " FOR ", " ") + ;
Alltrim(Filter)+ ;
IIF(UPPER(Type)="CANDIDATE"," CANDIDATE","") + ;
IIF(TAGCOUNT(lcTableName) > 0, " ADDITIVE", "")
Second, you haven't allowed for UNIQUE indexes (I don't use them in permanent tags myself, but you need to check if you are supporting them.
Third, in order to get the most benefit from recreating all indexes, you should issue a DELETE TAG ALL, so that you make certain to recover any disk space from index bloat in the current .CDX file. Doing this has some serious .DBC ramifications that may require you to rebuild some of the information in your database container.
You need to make certain that the file has been opened exclusively before doing any of this. I also would issue a USE and FLUSH afterwards to make certain that the updated .CDX file is forced out to disk completely.
I made the decision to use SDT a couple of years back rather than rolling my own table, index and .DBC maintenance; it's an amazingly powerful utility that can be incorporated into your products and distributed royalty-free once you buy it. I couldn't come close to duplicating the functionality or reliability of SDT in a reasonable amount of time; Doug Hennig has done a great job of supporting his product and enhancing SDT to date. It's supported by most of the major frameworks on the market (in my case, since I use a framework built around Visual MaxFrame Pro, all the necessary hooks are right there in the framework), and uses the DBCX2 standard to provide extensibility to the .DBC that has very wide product support as well.