Anh_Tran Posted January 15, 2003 Posted January 15, 2003 Hi All File A , 2 fields , Field A1 = 12 Field A2 = nil so unique key= 12nil so first time I go from File A to File B ..I create a record in File and set unique key of File B = 12nil Second time I change Field A1= 12 Field A2 = 123 so uniquekey = 12123 So How can I go From File A to File B which don't create new record in File B but go to the same record of File B (12nil) and change unique key of File B = 12123. Somebody can help me with this since I tried many ways but no idea how to implement that ...since I know that one unique key to one unique can not change like that? I really need your help Thanks All
Kurt Knippel Posted January 15, 2003 Posted January 15, 2003 Start with the following premise: Keys NEVER change, keys are NOT accessible or ever seen by the user and user/system modifiable values are NOT keys. So create a unique key to link the records and establish a relationship via this field. Then you can use this relationship to modify those other identifiers as they change. I suggest looking into the following thread for my implementation of a unique key system, which is the primary linking system for the relationships, and can be used when other user-defined linking systems (such as CustomerID, or InvoiceNumber, etc) need to be modified. CaptKurt's Unique Key System
Anh_Tran Posted January 15, 2003 Author Posted January 15, 2003 Thanks Capkurt, you make my day... That is what i am thinking but could not figure out how to make primary key. Once again Thanks
Anh_Tran Posted January 15, 2003 Author Posted January 15, 2003 But if I duplicate it gives me the same primary ...how can we avoid it? I want that when it is duplicate it gives different primary ... Any idea? Thanks
Kurt Knippel Posted January 15, 2003 Posted January 15, 2003 I control all record creation and duplication through scripting and I do not allow user access to the menu for record creation. So they cannot choose Duplicate Record or press Command-D. They must press a "Duplicate" button on the layout. This then allows me to assign a new PrimaryID to the duplicated record, as well as whatever other functions need to happen upon duplication.
Anh_Tran Posted January 17, 2003 Author Posted January 17, 2003 When I duplicate I got a new primary key ...do you know how to get a duplicate of related file with the new primary key when I duplicate the original file. Thanks
Kurt Knippel Posted January 17, 2003 Posted January 17, 2003 To duplicate a set of related records, you'll need to do some scripting. Basically I do the following: Store Original PrimaryID (i.e. CustomerID_pkey) Duplicate Record, Assign New PrimaryID, Store New PrimaryID Goto Related Records by Original PrimaryID Loop Through Related Records, Duplicate Record, Set the ForeignKey (i.e. CustomerID_fkey) to the New PrimaryID. Also make sure to Assign a new PrimaryID (i.e. InvoiceID_pkey) to the duplicated record. Eventually you will have duplicated all related records and set thier ForeignKey to the new PrimaryID.
Anh_Tran Posted January 17, 2003 Author Posted January 17, 2003 Thanks Capkurt ... I got your idea ... Once more ...thanks ...because that problem gives me headache
Recommended Posts
This topic is 8037 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now