Newbies rav2610 Posted March 11, 2004 Newbies Posted March 11, 2004 Hi....I have an issue with adding a surrogate key for already existing database. I have crated a treatment key as a surrogate key for all values of medical record number..but am unable to populate it with incrementing numbers. Tha maximum I could get to was...populating the treatment key with same value. Plz help me to change these numbers to incrementing numbers...rather than same vakue. I do not know which category to use in the scriptmaker to initiate a count to increment numbers by one after each loop. Plz help me out with this!!! Version: v6.x Platform: Windows XP
CyborgSam Posted March 11, 2004 Posted March 11, 2004 If I'm understanding your question correctly: 1) Define a global number field "LoopCounter" 2) show all records you want to set the surrogate in and sort the way you want them to increment. 3) The important parts of the script: Set Field ["LoopCounter", "1"] Loop SetField ("surrogateKey", "LoopCounter") Exit Loop If ["Status (CurrentRecordNumber) = Status (CurrentRecordCount)"] Goto Record/Request/Page [Next] Set Field ["LoopCounter", "LoopCounter + 1"] End Loop Is this what you wanted to do?
Newbies rav2610 Posted March 14, 2004 Author Newbies Posted March 14, 2004 Thanks ...it did help a lot....i just had to reassign the value of loopcounter as the surrogate key and take the next value of loopcounter as previous record of loopcounter +1. that did it! thanks
CyborgSam Posted March 14, 2004 Posted March 14, 2004 I didn't mention this in my first post, but: Look at the script step Replace Contents. It replaces the contents of a field with a value which can be a serial #, a calculation, etc. It works across all records in the found set. It will be faster than the loop. In your case it would look like: Replace Contents [No dialog, "SurrogateKey", "Serial numbers"] Things to note: 1) It operates on records in the Found Set, if you want to do this for all records be sure to include a Show All records step before. 2) It uses the current sort order, so make sure the records are sorted the way you need. 3) Check the No dialog if you don't need to change anything in the replace dialog (like starting serial #, etc). Version: v7.x Platform: Mac OS X Panther
Recommended Posts
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