Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which is faster?
Message
 
To
13/05/2004 17:29:08
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00903686
Message ID:
00903877
Views:
69
Mike,

That is the method I am using, an id table. It is indicated in this portion of my message:

This procedure stores the last key value used for a field in a table in a id table that maintains values. The id table's structure looks like this:
talbe_name field_name last_key
table1        field1     1000


I have also explained why I am using GO BOTTOM to retrieve the maximum value.

Dawa

>Hi Dawa
>
>In a nutshell, create a new table that holds the last ID generated per data table in your system.
>
>Every time you want a new key, access the ID table, increment the last key on the record for the data table, and return that key as the new key.
>
>GO BOTTOM will not be reliable and as the size of the file grows, the performance will drop.
>
>>Hi Mike, Craig,
>>
>>Mike, thanks for the message.
>>
>>I think Craig wants to know the reason behind your goal because if you're doing this to generate a primary key there are alternatives.
>>
>>Sorry, Craig, I didn't make it clear enough. Yes, this is part of primary key generation procedure that's stored in my database. I am using VFP7, so Integer Auto Increment is not an option until I upgrade my project into VFP8.
>>1. The procedure takes a table name and a field name as parameters
>> they are used to search for (table name+field name) entry
>>2. If found, then
>> 2.1. get the maximum key value from the target table
>> 2.2. compare the max value against the last key
>> 2.2.1 if max is larger than last_key replace last key with the max value
>> 2.2.2 increment last key and return it
>>3. If not found, the entry is created
>>
>>In my inital procedure, I didn't have 2.2.1. I had to add this because an error occoured on one of our user's machines. In one of the target tables, two entries with the same key value appeared. Ever since I added this line, this instance hasn't happened yet. Since, this routine is frequently accessed (every time a record inserted into one of target tables), I would like find the most efficient approach.
>>
>>Any, better alternitives I will embrace.
>>
>>I am runing a test with three different approaches that I considering. I will post the result soon.
>>
>>Dawa
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform