Hi Carole,
What you need descending PK as default? You can before using set:
SET ORDER TO "primarykey" DESCENDING
Yes, VFP has not way how to create descending index with ALTER TABLE. But, you can use my a small utility FILE#
28060.
#INCLUDE "dbc.h"
SET PROCEDURE TO dbc.prg ADDITIVE
LOCAL lcAlias,liIDT,loDBC,luValue,liIDI
loDBC=CREATEOBJECT("_DBC")
lcAlias=SYS(2015)
=loDBC.OpenTable(HOME(2)+"\Tastrade\Data\tastrade.dbc",lcAlias,"EXCLUSIVE")
liIDT=loDBC.GetIDObject(lcAlias,_DBC_Table,"products")
=loDBC.ClearProperty(lcAlias,liIDT,_DBCID_PrimaryKey)
liIDI=loDBC.GetIDObject(lcAlias,_DBC_Table,"products.primarykey")
DELE NEXT 1
PACK
loDBC.CloseTable(lcAlias)
=loDBC.OpenTable(HOME(2)+"\Tastrade\Data\tastrade.dbc!products",lcAlias,"EXCLUSIVE")
INDEX ON blablalblabla TAG PRIMARYKEY DESCENDING CANDIDATE
loDBC.CloseTable(lcAlias)
=loDBC.OpenTable(HOME(2)+"\Tastrade\Data\tastrade.dbc",lcAlias,"EXCLUSIVE")
liIDT=loDBC.GetIDObject(lcAlias,_DBC_Table,"products")
=loDBC.SetProperty(lcAlias,liIDT,_DBCID_PrimaryKey,"primarykey")
liIDI=loDBC.GetIDObject(lcAlias,_DBC_Table,"products.primarykey")
=loDBC.SetProperty(lcAlias,liIDI,_DBCID_Prim_Cand,.T.)
loDBC.CloseTable(lcAlias)
RELEASE loDBC
RELEASE PROCEDURE dbc.prg
MartiJ
>Hi,
>
>I am writing a utility that uses ataginfo() to discover tags that are primary or candidate keys and then remove them from a table, storing the index info so that I can later restore them.
>
>In my restore utility I am able to do the following to restore the candidate indexes in either descending or ascending order in the cdx file:
>
>
lcTable = [Customer]
>lctagexpr = "icustomerid"
>lctagfilter = "icustomerid > 1000"
>lctagname = "customer"
>lctagproc = ["MACHINE"]
>lctagorder = "DESCENDING"
>
>index on &lctagexpr for &lctagfilter tag &lctagname ;
> collate &lctagproc &lctagorder additive
>
>
>I can also to the following to restore a primary key in ascending order:
>
>
alter table (m.lcTable) add primary key &lctagexpr ;
> for &lctagfilter tag &lctagname collate &lctagproc
>
>However in the VFP IDE it is possible to make a primary key that is in a descending order. I can not figure out how to do this programmatically. Functionally I can just use a candidate key, but then commands like primary()will not behave as they did pre-strip.
>
>Thanks!