I got this off the UT. Enjoy.
>Can anyone give me the skinny on how this works? (Behind-the-scenes stuff.)
>
>Thanks in Advance.
There is a tiny mouse cage. In the cage is a spinning wheel. There is also a
lepracan. When you add a record the lepracan temps the mouse with a piece of
magic cheese. This causes the mouse to run in the wheel, and VFP counts the
wheel rotations. The lepracaun just knows by magic when to give the mouse
the cheese... so, you get the next id.
Actually, I believe a few bytes unused in the .dbf header was stolen to
store the next id value. If you already have values, when you change the
type to auto-increment you can specify the 'next id' so it wont conflict
with your existing numbers.
Bob Archer
Stephen Russell
President
S.R. & Associates
Memphis TN
901.246-0159
You can also reset it to 0 if you've ZAPped the table.
Here's how GenDBC does it:
CREATE TABLE 'TEST1.DBF' NAME 'TEST1' (FIELD1 C(10) NOT NULL, ;
FIELD2 I NOT NULL, ;
FIELD3 M NOT NULL, ;
FIELD4 I NOT NULL AUTOINC NEXTVALUE 5 STEP 3)
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org=20
-----Original Message-----
From: profox-admin@leafe.com [mailto:profox-admin@leafe.com] On Behalf =
Of
Stephen Russell
Sent: Friday, February 07, 2003 9:46 AM
To: profox@leafe.com
Subject: Secret to Auto Increment ID in VFP8
I got this off the UT. Enjoy.
>Can anyone give me the skinny on how this works? (Behind-the-scenes =
stuff.)
>
>Thanks in Advance.
There is a tiny mouse cage. In the cage is a spinning wheel. There is =
also a
lepracan. When you add a record the lepracan temps the mouse with a =
piece of
magic cheese. This causes the mouse to run in the wheel, and VFP counts =
the
wheel rotations. The lepracaun just knows by magic when to give the =
mouse
the cheese... so, you get the next id.
Actually, I believe a few bytes unused in the .dbf header was stolen to
store the next id value. If you already have values, when you change the
type to auto-increment you can specify the 'next id' so it wont conflict
with your existing numbers.
Bob Archer
Stephen Russell
President
S.R. & Associates
Memphis TN
901.246-0159
[excessive quoting removed by server]
Now that I've upped from fp-6 to fp-9, I want to change a few tables that
use an integer idno as a primary key to an auto increment type. The only
reason these tables need a primary key is so I can update their values
through a view. I learned that the hard way in a football data base when I
would mark 1-game as a conference game and then find that many games were
also checked also. Will it require me to go through all the tables, views,
and related forms then reset the data type? I'm not good at generating the
next higher idno from a list that is filtered. In this case I keep an admin
table that contains the next game idno to use (occasionally fails).
Gary Jeurink
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/A9C7A1A6137340679FE5C9FD15E3BEAE@OwnerPC
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Gary Jeurink wrote on 2012-08-22:
> Now that I've upped from fp-6 to fp-9, I want to change a few tables that
> use an integer idno as a primary key to an auto increment type. The only
> reason these tables need a primary key is so I can update their values
> through a view. I learned that the hard way in a football data base when
I
> would mark 1-game as a conference game and then find that many games were
> also checked also. Will it require me to go through all the tables,
views,
> and related forms then reset the data type? I'm not good at generating
the
> next higher idno from a list that is filtered. In this case I keep an
admin
> table that contains the next game idno to use (occasionally fails).
>
>
> Gary Jeurink
>
Gary,
I don't use views.
I believe changing a column to auto-increment is not a breaking change with
the views. I may be wrong, perhaps others have an idea.
Tracy Pearson
PowerChurch Software
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/001901cd80b3$76e43120$64ac9360$@powerchurch.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Create a little test database with a couple of test views and
experiment!
--
Alan Bourke
alanpbourke (at) fastmail (dot) fm
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/1345707352.7962.140661118464229.0C3CFA32@webmail.messagingengine.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On Wed, August 22, 2012 6:14 pm, Tracy Pearson wrote:
> I believe changing a column to auto-increment is not a breaking change
> with the views. I may be wrong, perhaps others have an idea.
You can't have the AutoIncrement key field set as updatable, unless I'm
mistaken?
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/2a1df952d80ddb02ea70fdffac972239.squirrel@webmail.dssco.net
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 8/22/12 12:07 PM, Gary Jeurink wrote:
> Now that I've upped from fp-6 to fp-9, I want to change a few tables that
> use an integer idno as a primary key to an auto increment type. The only
> reason these tables need a primary key is so I can update their values
> through a view. I learned that the hard way in a football data base when I
> would mark 1-game as a conference game and then find that many games were
> also checked also. Will it require me to go through all the tables, views,
> and related forms then reset the data type? I'm not good at generating the
> next higher idno from a list that is filtered. In this case I keep an admin
> table that contains the next game idno to use (occasionally fails).
Over the years of my experience with Fox and VFP, I used all kinds of ways to
generate primary keys, and in retrospect the best ever was concatenating the machine
name with the output of sys(2015).
In my opinion, auto-incrementing integer keys are to be avoided.
I use 40-char GUID's in my Python work, but to get those in VFP you'd have to rely on
an external library which could slow you down compared to VFP's sys(2015).
Paul
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/50366BA0.3080707@ulmcnett.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
>On Thu, Aug 23, 2012 at 10:42 AM, Paul McNett <p@ulmcnett.com> wrote:
> Over the years of my experience with Fox and VFP, I used all kinds of ways to
> generate primary keys, and in retrospect the best ever was concatenating the machine
> name with the output of sys(2015).
>
Wasn't it true at one time that SYS(2015) didn't guarantee uniqueness?
More like a "really really really good try" sort of thing?
--
Matt Jarvis
Eugene, Oregon USA
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAPT54rbo9_aQL6gqi111hBeZ2Wv5rtNGNbH1h4a-qndZR2+LkQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On Thu, Aug 23, 2012 at 12:35 PM, MB Software Solutions General
Account <mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
> On Wed, August 22, 2012 6:14 pm, Tracy Pearson wrote:
>> I believe changing a column to auto-increment is not a breaking change
>> with the views. I may be wrong, perhaps others have an idea.
>
>
> You can't have the AutoIncrement key field set as updatable, unless I'm
> mistaken?
--------------------------
Why would you ever update a PKey? It is just a pointer.
--
Stephen Russell
Sr. Analyst
Ring Container Technology
Oakland TN
901.246-0159 cell
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAJidMY+10XdTUS97Lke-Pc-G=+wpK=aixJj2PWgaexvQRtYezQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Stephen Russell wrote on 2012-08-23:
> On Thu, Aug 23, 2012 at 12:35 PM, MB Software Solutions General
> Account <mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
> On Wed, August 22, 2012 6:14 pm, Tracy Pearson wrote:
>>> I believe changing a column to auto-increment is not a breaking change
>>> with the views. I may be wrong, perhaps others have an idea.
>>
>>
>> You can't have the AutoIncrement key field set as updatable, unless I'm
>> mistaken?
>> --------------------------
>>
> Why would you ever update a PKey? It is just a pointer.
>
Stephen,
Converting an existing field to be an AutoIncrement and that table is
already connected to a view. The view would probably have the field set as
Updateable. So, this is one of the problems that the OP was asking for.
Tracy Pearson
PowerChurch Software
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/000d01cd8157$fcd41df0$f67c59d0$@powerchurch.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.