Board index » delphi » Paradoxe Database and Primary Key

Paradoxe Database and Primary Key

Hi,

I am trying to change the values of a primary key and it won't let me. I
am using a relation database. I have a main table and 3 related tables.
I am trying to change the values in the field that has the primary key.
I can't find any way to do it.

Is there a way?

The problem is the table has a list of Authors and they are not in order
by name they are in order of the primary key which is how they were
entered. I want to reorder the table so the AuthorNames are in alpha
order. I've got everything working except the final change of AUTHORID
to AUTHORNAME.
Right now AUTHORID may be 11 and the Name is A.A. and should be 1. I
want to change the 11 to a 1.

Please help.

I have Delphi Version 2.0.
Please email me at chris.iver...@bentley.com

Thanks,

Chris I.

 

Re:Paradoxe Database and Primary Key


Chris,

    Have you tried to use an Index based on Author Name Field and then
invoking that index?  That should put your Author Names into Alphbetical
order no matter what the primary key is :)

Ryan Meyers

Quote
Chris Iverson <chris.iver...@bentley.com> wrote in message

news:3777C033.40E8461C@bentley.com...
Quote
> Hi,

> I am trying to change the values of a primary key and it won't let me. I
> am using a relation database. I have a main table and 3 related tables.
> I am trying to change the values in the field that has the primary key.
> I can't find any way to do it.

> Is there a way?

> The problem is the table has a list of Authors and they are not in order
> by name they are in order of the primary key which is how they were
> entered. I want to reorder the table so the AuthorNames are in alpha
> order. I've got everything working except the final change of AUTHORID
> to AUTHORNAME.
> Right now AUTHORID may be 11 and the Name is A.A. and should be 1. I
> want to change the 11 to a 1.

> Please help.

> I have Delphi Version 2.0.
> Please email me at chris.iver...@bentley.com

> Thanks,

> Chris I.

Re:Paradoxe Database and Primary Key


Chris - using a value like name as a primary key is not a good idea for many
reasons, such as - suppose you have 2 authors with the same name... You'll
have to change one to make it unique  You should probably leave the Author
ID field, and create a secondary index to sort the names on..

--
David Reed
Diamond Software Group
Oasis Rep Software, Inc
www.diamondsg.com
www.oasisrep.com

Re:Paradoxe Database and Primary Key


I am not sure I understand your question. If you have referential integrity
defined between the two tables you must have the Cascade option selected to
be able to change the value of a master record's primary key and have that
value cascade to the foreign key field of the detail table.

If you want to change the data type of the primary key you must remove the
referential integrity declaration first.

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Re:Paradoxe Database and Primary Key


Quote
>I am trying to change the values of a primary key and it won't let me. I
>am using a relation database. I have a main table and 3 related tables.
>I am trying to change the values in the field that has the primary key.
>I can't find any way to do it.

>Is there a way?

It should work as long as you don't have referential integrity set on it but it
is really poor design to have a table where you need to change the primary key.

How about using a secondary index to order the table?

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Paradoxe Database and Primary Key


Actually what I am trying to do is Print so the Authors are in alpha
order. In the main table I have the title and the AUTHORID number. This
is primary index linked to another table that has the AUTHORID and the
AUTHORNAME. I tried using another index on the AUTHORNAME in table2 but
it didn't print right.
What I was trying to do with the replacing of the Primary index is to
put the AUTHORID in alpha order to the name in the main table then
print.
I am using the Quick Report designer to print from. How can I print
using the AUTHORNAME sort order in Table2 when Table1 is related to the
other tables?

I will look at it tonight.

Chris I.

Re:Paradoxe Database and Primary Key


In that case use a query to join the two tables and sort by Author Name.

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Re:Paradoxe Database and Primary Key


Quote
>I am using the Quick Report designer to print from. How can I print
>using the AUTHORNAME sort order in Table2 when Table1 is related to the
>other tables?

run the report from a query where you can use Order by to sort the records the
way you need them.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads