You could try creating another table with a primary key set up as auto-increment. Insert into here and pull back the primary key created. Then use this as the unique identifier for your record on the other table.
Delphi allows you to get back the identifier that has been created by "your" last insert so it should be safe. Hope this helps Chris From: delphi-db-requ...@elists.org To: delphi-db@elists.org Date: 23/11/2009 08:08 AM Subject: Delphi-DB Digest, Vol 71, Issue 2 Send Delphi-DB mailing list submissions to delphi-db@elists.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-db or, via email, send a message with subject or body 'help' to delphi-db-requ...@elists.org You can reach the person managing the list at delphi-db-ow...@elists.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Delphi-DB digest..." Today's Topics: 1. Creating Primary Key Field or unique filed value on the fly (Jason Richards) 2. Re: Creating Primary Key Field or unique filed value on the fly (Garth S. Wilcox) ---------------------------------------------------------------------- Message: 1 Date: Fri, 20 Nov 2009 16:01:31 -0000 From: "Jason Richards" <ja...@healingbreeze.net> Subject: Creating Primary Key Field or unique filed value on the fly To: <delphi-db@elists.org> Message-ID: <05f8aa57f27e214d84894231040e5f861fc...@breeze-mx.breeze.local> Content-Type: text/plain; charset="us-ascii" I am working with BDE with queries to a Pervasive SQL database. Some of the tables do not have primary keys and I need to create them on the fly. When I say primary key fields I need to create a unique value for each record each time the query is executed. Does anyone have any ideas about how I can do this? I have numerous calculations going on in calculated fields with functions etc and all is great, except this and I need a little insight! Thanks in advance Jason Richards ------------------------------ Message: 2 Date: Sat, 21 Nov 2009 08:55:51 -0500 From: "Garth S. Wilcox" <gar...@mindspring.com> Subject: Re: Creating Primary Key Field or unique filed value on the fly To: Moderated discussion list about database programming with Borland's Delphi <delphi-db@elists.org> Message-ID: <4b07f167.1080...@mindspring.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Several thoughts 1) Use a GUID for the key. It's a little large, but Delphi generates it quick and it is unique 2) use sequential keys and have a database table where the last (or next) key for each table is stored. Old school and might be a problem if the table already has some keys. yours don't. Also can be a bottle neck for multiuser/application databases. 3) Some database systems have a feature that will generate the next key (sequence) > I am working with BDE with queries to a Pervasive SQL database. Some of > the tables do not have primary keys and I need to create them on the > fly. When I say primary key fields I need to create a unique value for > each record each time the query is executed. > > > > Does anyone have any ideas about how I can do this? > > > Jason Richards > > ------------------------------ _______________________________________________ Delphi-DB mailing list Delphi-DB@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-db End of Delphi-DB Digest, Vol 71, Issue 2 **************************************** _______________________________________________ Delphi-DB mailing list Delphi-DB@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-db