Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining Available Indexes for a VFP table, using SPT
Message
From
02/09/2002 05:52:31
 
 
To
27/08/2002 08:00:15
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00693965
Message ID:
00695897
Views:
16
Hello,

It is possible to select information directly from the dbc, so for example to get a list of all the indexes you could do something like:

SQLexec (gVFPHandle, "Select * from data1.dbc where objecttype = 'Index'", "CurIndexes")

This could easily be scoped to return indexes for a specific table using the objectid and parentid fields.

To retrieve the expression, you could loop the indexes and select the key(). Eg:

?SQLEXEC( gVFPHandle, "Select KEY(2, 'table1') from table1 where recno()=1")

Unfortunately, the where recno = 1 is required so that you do not get an expression for every record... and it assumes you have at least one record.

Is this what you where after?

Mace



>Hi,
>
>How can I determine all indexes and their corresponding index expressions for a VFP table that is being accessed via SPT?
>
>As an example, below is how I implemented the logic to obtain indexes for SQL Server and Oracle tables.
>
>TIA
>
>Fernando
>
>* Parameters
>
> gSQLHandle  = Handle of the ODBC connection
> cTableName  = Table to obtain indexes
> cTableOwner = Owner of table
>
>* Expression for a SQL Server Table
>
> cSelectStr = "Exec sp_helpindex ?cTableName"
>
>* Expression for an Oracle Table
>
> cSelectStr = "Select Table_Name     ,                              " + ;
>              "       Table_Owner    ,                              " + ;
>              "       Index_Name     ,                              " + ;
>              "       Column_Position,                              " + ;
>              "       Column_Name    ,                              " + ;
>              "       Descend                                       " + ;
>              "                                                     " + ;
>              "From   All_Ind_Columns                               " + ;
>              "                                                     " + ;
>              "Where  Trim (Lower (Table_Name )) = ?cTableName  and " + ;
>              "       Trim (Lower (Table_Owner)) = ?cTableOwner     " + ;
>              "                                                     " + ;
>              "Order  By Index_Name, Column_Position                "
>
>* Executes the SQL Command
>
> SQLexec (gSQLHandle, cSelectStr, "CurIndexes")
>
>* Logic to Build String with Index Expressions
>
>. . .
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform