| Subject |
Re: creating unique key : usingprimair key and foreign key |
| From |
edward racht <e.racht@gmail.com> |
| Date |
Sat, 6 Feb 2021 10:08:23 -0500 |
| Newsgroups |
dbase.getting-started |
Greetings,
Does any of the following reference contribute to your discussion?
http://www.goldenstag.net/dbase/Tutorial/02a_DBFsAndIndexes.htm
Need AutoIncrement Type Field, But Don't Want Problems?
Periodically someone comes into the newsgroups and complains about how
the autoincrement field messed them up completely and they don't want to
use autoincrement fields, but they need that functionality. (Typically
these are the issues mentioned above -- if you spend a little time with
them, you can deal with the issues. Using Bowen's code above most people
have few problems with them.)
The dUFLP (mentioned above) has a bit of code you can use in your own
application, created years ago, before the AutoIncrement field type was
created. The code in the dUFLP was created based on code by Romain
Streiff for older versions of dBASE. If you examine the header it gives
a lot of detail, but basically this is how you work with it:
set procedure to :dUFLP:SeqValue.cc
// create object
oSeq = new SeqValue()
nNewValue = oSeq.Increment( "MyTablename", "MyPrimaryKeyField" )
// assume q is a reference to a valid query:
q.rowset.beginAppend()
q.rowset.fields["MyPrimaryKeyField"].value := nNewValue
q.rowset.save()
// cleanup
close procedure :dUFLP:SeqValue.cc
oSeq.release()
ed
|
|