INDICES.

Find information about the indexes associated with a file

  Return to Contents Page   Return to Knowledge Base   Return to JAC Home Page

Syntax:

INDICES(filevar { , index-name } )

Description:

This function has a dual purpose. In its first invokation whereby a single parameter is passed, assumed to be a file descriptor, will return a dynamic array of all the index names associated with the file. In its second invokation two parameters are passed, the first being a file variable again and the second the name of an index. In this case the return value from the function will be a dynamic array containing information about the specified index.

In the second invokation, the dynamic array has the following attributes:

Attribute Description
<1> SORT criteria This shows the components that the index is sorted by. For example if you want to create an index sorted left justified on attribute 1 and then sub-sorted right justified in descending order on attribute 2 you might create the index with "BY 1 BY-DR 2". In this example this attribute returned by INDICES would be "ALDR" to show the first index field is sorted ascending left justified and then sub-sorted descending right justified.
<2> TYPE description This describes which of the indexing emulations have been used when creating the index. Currently the only possible value is "JBASE"
<3> INDEX definition This is the actual index definition used on the command line when the index was created. Hence if you created an index with the command "create-index filename indexname by 1" then the data returned in this attribute will be "by 1".
<4> LOOKUP definition This is the value of any conversion to apply when the data is looked up using the query-index command. This is therefore the data passed with the -l option to create-inde
<5> CREATE time This is the time, in UTC format that an index definition was first created.
<6> MODIFY time This is the time in UTC format that an index definition was last modified.
<7> DEBUG flag A numeric of 0 or 1. If 1 is returned it shows the -d option was used when the index was created and so when the index is being built it can be debugged in the normal way using the jBC debugger.
<8> NULL flag A numeric of 0 or 1. If 1 is returned is shows that null index keys will be ignored.
<9> CASE flag A numeric of 0 or 1. If a 1 is returned it shows the index is case insensitive.
<10> MULTI-VALUE flag A numeric of 0 or 1. If a 1 is returned it shows updates will be done on a multi-value basis. Hence if an update occurs and the attribute in the record has 3 values, each value will create its own index key.
<11> SYNC flag A numeric of 0 or 1. If a 1 is returned it shows the index data is in synchronisation with the file data and so the index can be used. If a 0 is returned it shows the index data is out of step and needs to be rebuilt with the rebuild-index command.
<12> VALUE MAX count If the (Vnn option was used on a create-index command, this will limit us to the first nn values per attribute. This value is shown here. A value of 0 shows the option not in effect.

Example:

The following code example show how a file called "CUSTOMERS" can have some of the information about all of its indexes displayed.

filename = "CUSTOMERS"

OPEN filename TO filevar ELSE STOP 201,filename

index.list = INDICES(filevar)

index.count = DCOUNT(index.list,@AM)

IF NOT(index.count) THEN

    CRT filename:" has NO defined indexes"

    STOP

END

FOR index.next = 1 TO index.count

    index.name = index.list<index.next>

    index.data = INDICES(filevar,index.name)

    CRT

    CRT "Index name = ":index.name

    CRT "Definition = ":index.data<3>

    CRT "Lookup code = ":index.data<4>

    CRT "Create date = ":OCONV(INT(index.data<5>/86400)+732,"D")

    CRT "Create time = ":OCONV(MOD(index.data<5>,86400),"MTS")

NEXT index.next

http://807199.827977/r5/knowledgebase/manuals/3.0/SecondaryIndexes/html/indices.htm last modified on 06/19/09 05:29 AM