Subject Re: CREATE INDEX
From Mervyn Bick <invalid@invalid.invalid>
Date Sun, 10 Dec 2017 08:23:53 +0200
Newsgroups dbase.getting-started

On 2017-12-09 10:51 PM, Mustansir Ghor wrote:
> Dear All
>
> I have following SQL statement which is executed on pushbutton
>
> SELECT * FROM SALESCR R JOIN ghor5 J ON (R.SNO=J.SNO) WHERE  R.Sdate=:DPDATE save to ghor
>
> from the above statement the ghor.dbf table that was created I am using in a query. The rowset generated from the query needs to be indexed. Can anybody guide me how to create the index so that I can use it in the rowset.indexname.
>
> Best Regards
> Mustansir
>


You are creating the table ghor from scratch so if you order the data
you are placing in it you may not even need and index.

SELECT * FROM SALESCR R JOIN ghor5 J ON (R.SNO=J.SNO) WHERE
R.Sdate=:DPDATE ORDER BY sno save to ghor

You can place whatever fields you need, separated by a comma, in the
ORDER BY clause irrespective of their types.

If you really need an index

use ghor exclusive
index on sno tag sno
use

In this case if you need a compound index you need to convert any field
which isn't character to character before including it in the index
expression.  If you ever need to include a date in the index expression
use DTOS(datefieldname) which will give you the data in chronological
order no matter what the date format is set to.  NEVER use trim() when
creating an index.

See INDEX in the help file.

The big question is, however, why are you creating the table ghor in the
first place?

Why not use  SELECT * FROM SALESCR R JOIN ghor5 J ON (R.SNO=J.SNO) WHERE
  R.Sdate=:DPDATE ORDER BY sno  as the sql property of a query instead
of using ghor in the query?

Mervyn