Board index » delphi » New sorting an existing PARADOX table?

New sorting an existing PARADOX table?

Hello Bits&Bytes,

well, I know to re-indexing (=new sorting) an exesting
DBASE-Table(AddIndex/DeleteIndex......).

But PARADOX is paradox. I think the primaryindex is the sortkey (or isn't
it?). And how can I (with the smallest work, of course) an existing
PARADOX-table new sorting? DeleteIndex and AddIndex isn't the solution to
remove the primary key. Who can show me the way (...to the next whisky bar,
I know....)?

Let the mouses life!

 

Re:New sorting an existing PARADOX table?


The song came from Jim Morrison: Alabama Song

"Show me the way to the next whisky bar, oh don't ask me why: I tell you we
must die....."

Keep the glasses full!

"Caroll Ferkl" <Caroll.Fe...@ntv.de> schrieb im Newsbeitrag
news:3bdf80eb$1_2@dnews...

Quote
> Hello Bits&Bytes,

> well, I know to re-indexing (=new sorting) an exesting
> DBASE-Table(AddIndex/DeleteIndex......).

> But PARADOX is paradox. I think the primaryindex is the sortkey (or isn't
> it?). And how can I (with the smallest work, of course) an existing
> PARADOX-table new sorting? DeleteIndex and AddIndex isn't the solution to
> remove the primary key. Who can show me the way (...to the next whisky
bar,
> I know....)?

> Let the mouses life!

Re:New sorting an existing PARADOX table?


Are you saying that you want to view the Paradox table in different orders?
If so, just create an index for each order then at runtime use

Table1.IndexName := 'TheIndexName';

to set the active index.

--
Bill
(TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


This only works with DBASE NOT with PARADOX!!!!

procedure TDbFrm.DbGridTitleClick(Column: TColumn);
var
  IndexListe : TStrings;

begin
try
 IndexListe := TStringList.Create();
 MainFrm.MainTable.GetIndexNames(IndexListe);

 //Hat die (Paradox-)Tabelle einen Prim?rundex?
 if (IndexListe.Count = 0) and
(AnsiLowerCase(ExtractFileExt(MainFrm.MainOpnDlg.FileName)) = '.db') then
   begin // Prim?rIndex erzeugen: 1.Feld
     MainFrm.MainTable.AddIndex('',Column.FieldName,[IXprimary])
   end  //kein Index
  else
   begin
   end; //Index vorhanden

 //Ist Index? vorhanden?
 if IndexListe.IndexOf(Column.FieldName) > -1 then
   begin
     // und anzeigen
     MainFrm.MainTable.IndexName := Column.FieldName;
   end  //Index vorhanden
  else
   begin
     // Index mit Tabellenkopfname erzeugen
     MainFrm.MainTable.AddIndex('',Column.FieldName,[]);
     // und anzeigen
     MainFrm.MainTable.IndexName := Column.FieldName;
   end; //kein Index
finally
 IndexListe.Free();
end; //try
end;

Regards!

"Bill Todd (TeamB)" <bill.nos...@dbginc.com> schrieb im Newsbeitrag
news:3be029de$1_1@dnews...

Quote
> Are you saying that you want to view the Paradox table in different
orders?
> If so, just create an index for each order then at runtime use

> Table1.IndexName := 'TheIndexName';

> to set the active index.

> --
> Bill
> (TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


You need to create a Secondary Index Field I dont know how to create them in
a program but I have Created them in paradox under restructure secondary
Indexs note they can be unstable in a high use table that is constantly being
updated. once they are created they can be used like Bill says.
Quote
Caroll Ferkl wrote:
> This only works with DBASE NOT with PARADOX!!!!

> procedure TDbFrm.DbGridTitleClick(Column: TColumn);
> var
>   IndexListe : TStrings;

> begin
> try
>  IndexListe := TStringList.Create();
>  MainFrm.MainTable.GetIndexNames(IndexListe);

>  //Hat die (Paradox-)Tabelle einen Prim?rundex?
>  if (IndexListe.Count = 0) and
> (AnsiLowerCase(ExtractFileExt(MainFrm.MainOpnDlg.FileName)) = '.db') then
>    begin // Prim?rIndex erzeugen: 1.Feld
>      MainFrm.MainTable.AddIndex('',Column.FieldName,[IXprimary])
>    end  //kein Index
>   else
>    begin
>    end; //Index vorhanden

>  //Ist Index? vorhanden?
>  if IndexListe.IndexOf(Column.FieldName) > -1 then
>    begin
>      // und anzeigen
>      MainFrm.MainTable.IndexName := Column.FieldName;
>    end  //Index vorhanden
>   else
>    begin
>      // Index mit Tabellenkopfname erzeugen
>      MainFrm.MainTable.AddIndex('',Column.FieldName,[]);
>      // und anzeigen
>      MainFrm.MainTable.IndexName := Column.FieldName;
>    end; //kein Index
> finally
>  IndexListe.Free();
> end; //try
> end;

> Regards!

> "Bill Todd (TeamB)" <bill.nos...@dbginc.com> schrieb im Newsbeitrag
> news:3be029de$1_1@dnews...
> > Are you saying that you want to view the Paradox table in different
> orders?
> > If so, just create an index for each order then at runtime use

> > Table1.IndexName := 'TheIndexName';

> > to set the active index.

> > --
> > Bill
> > (TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


Hello Donald,

in the code you can see that I create new secondaryindex with

Quote
> >      MainFrm.MainTable.AddIndex('',Column.FieldName,[]);

and it works well with DBASE but not with PARADOX (and first you need to
build a primary-index, like in the codeexample).

But Thanks for your effort!
C.F

"Donald S. Bossen" <sbos...@jbimporters.com> schrieb im Newsbeitrag
news:3BE08057.29341F6A@jbimporters.com...

Quote
> You need to create a Secondary Index Field I dont know how to create them
in
> a program but I have Created them in paradox under restructure secondary
> Indexs note they can be unstable in a high use table that is constantly
being
> updated. once they are created they can be used like Bill says.

> Caroll Ferkl wrote:

> > This only works with DBASE NOT with PARADOX!!!!

> > procedure TDbFrm.DbGridTitleClick(Column: TColumn);
> > var
> >   IndexListe : TStrings;

> > begin
> > try
> >  IndexListe := TStringList.Create();
> >  MainFrm.MainTable.GetIndexNames(IndexListe);

> >  //Hat die (Paradox-)Tabelle einen Prim?rundex?
> >  if (IndexListe.Count = 0) and
> > (AnsiLowerCase(ExtractFileExt(MainFrm.MainOpnDlg.FileName)) = '.db')
then
> >    begin // Prim?rIndex erzeugen: 1.Feld
> >      MainFrm.MainTable.AddIndex('',Column.FieldName,[IXprimary])
> >    end  //kein Index
> >   else
> >    begin
> >    end; //Index vorhanden

> >  //Ist Index? vorhanden?
> >  if IndexListe.IndexOf(Column.FieldName) > -1 then
> >    begin
> >      // und anzeigen
> >      MainFrm.MainTable.IndexName := Column.FieldName;
> >    end  //Index vorhanden
> >   else
> >    begin
> >      // Index mit Tabellenkopfname erzeugen
> >      MainFrm.MainTable.AddIndex('',Column.FieldName,[]);
> >      // und anzeigen
> >      MainFrm.MainTable.IndexName := Column.FieldName;
> >    end; //kein Index
> > finally
> >  IndexListe.Free();
> > end; //try
> > end;

> > Regards!

> > "Bill Todd (TeamB)" <bill.nos...@dbginc.com> schrieb im Newsbeitrag
> > news:3be029de$1_1@dnews...
> > > Are you saying that you want to view the Paradox table in different
> > orders?
> > > If so, just create an index for each order then at runtime use

> > > Table1.IndexName := 'TheIndexName';

> > > to set the active index.

> > > --
> > > Bill
> > > (TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


The phrase "does not work" is not very informative. It would help to know
specifically what does not work. I will assume that the AddIndex call is in
fact creating the primary index.

Quote
>> if IndexListe.IndexOf(Column.FieldName) > -1 then

Column.FieldName appears to contain the name of the column on which you
created the primary index. It does _not_ contain the name of the index
(which is always null for the primary index on a Paradox table) so calling
IndexOf will not find the name of the index you just created.

Hope this helps.

--
Bill
(TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


Hello Bill,

Well, the basic problem is, I have tables without index (DBASE / PARADOX )
and I want to sort the data when the user click on the title. This should be
the index for the table. This works well with DBASE because I don't need a
primary index like in PARADOX , can create new secondary index and set with
IndexName := 'xyz'.

But in Paradox I need the primary index to build the secondary index (Error:
'No primary Index'). So I take the first title-click for the primary index.
This seems to be OK and I have a primary index.

The next click (on other title) should build and set a secondary index. But
in the AddIndex I get an EDBEngineError in German: 'Fr diese Operation ist
Basisreihenfolge erforderlich' ( " This operation required basis succession"
I hope this a correct translation?)

Bill, please can you explain me how I can create/set primary and secondary
indexes for an existing PARADOX-Table in the examplecode?

Regards
C.F

 "Bill Todd (TeamB)" <bill.nos...@dbginc.com> schrieb im Newsbeitrag
news:3be0c446$1_2@dnews...

Quote
> The phrase "does not work" is not very informative. It would help to know
> specifically what does not work. I will assume that the AddIndex call is
in
> fact creating the primary index.

> >> if IndexListe.IndexOf(Column.FieldName) > -1 then

> Column.FieldName appears to contain the name of the column on which you
> created the primary index. It does _not_ contain the name of the index
> (which is always null for the primary index on a Paradox table) so calling
> IndexOf will not find the name of the index you just created.

> Hope this helps.

> --
> Bill
> (TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


One of the restrictions of Paradox tables is that the primary key must
consist of the first N fields in the table. If you have a table whose
structure is

EmployeeId
SocialSecurityNumber
FirstName
LastName

You cannot make SocialSecurityNumber the primary key. The only single field
that can be used for the primary key is EmployeeId. If you wanted a composit
primary key you could use EmployeeId and SocialSecurityNumber but not
EmployeeId and LastName. If you are attempting to create the primary key on
the first column the user clicks on that is the problem.

--
Bill
(TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


Thanks Bill,

I'll try it with annother table structure and given primary key.

Regards
C.F

"Bill Todd (TeamB)" <bill.nos...@dbginc.com> schrieb im Newsbeitrag
news:3be15ec2$1_2@dnews...

Quote
> One of the restrictions of Paradox tables is that the primary key must
> consist of the first N fields in the table. If you have a table whose
> structure is

> EmployeeId
> SocialSecurityNumber
> FirstName
> LastName

> You cannot make SocialSecurityNumber the primary key. The only single
field
> that can be used for the primary key is EmployeeId. If you wanted a
composit
> primary key you could use EmployeeId and SocialSecurityNumber but not
> EmployeeId and LastName. If you are attempting to create the primary key
on
> the first column the user clicks on that is the problem.

> --
> Bill
> (TeamB cannot answer questions received via email)

Re:New sorting an existing PARADOX table?


I found that IndexDefs.Add / AddIndex may still refuse to create a secondary
index
but that a TQuery with an SQL statement like:
CREATE ... INDEX ... ON ...
will do it.
Hope this helps.
Vianney

Other Threads