auto-incrementing a primary key 
Author Message
 auto-incrementing a primary key

Hello all,

Sorry, I'm a newbie to VFP 5.0 ...

I'm wondering how to auto-increment a primary key field for every record

I add in a table, and if it is possible to prefix this key with
something like "tv_" followed by the value.

Thanks very much in advance for your great help and greetings from
Switzerland

Rgis Piccand



Mon, 28 Aug 2000 03:00:00 GMT  
 auto-incrementing a primary key

There is no automatic method.  We created a record which holds
the value and lock and reference it each time.  Here's the code
we use.
* Gets the next id from the config file and returns it
* idfield - Which field in config holds id to get.
function GetNextId( idfield )
 local retval, done
 * Lock the file
 do while  flock( 'config' ) = .f.
 enddo

 * Save current value and increment it for next user
 retval = curval( idfield, "config" )
 replace (idfield) with retval+1 in config
 clear
 done = tableupdate(.t.,.t.,"config")
 if ! done
  error1(.t., "Error getting next id", idfield, str(error()),;
      message() )
 endif

 * Release config to other users
 unlock

 return retval
endproc

Quote:

>Hello all,

>Sorry, I'm a newbie to VFP 5.0 ...

>I'm wondering how to auto-increment a primary key field for every record

>I add in a table, and if it is possible to prefix this key with
>something like "tv_" followed by the value.

>Thanks very much in advance for your great help and greetings from
>Switzerland

>Rgis Piccand



Mon, 28 Aug 2000 03:00:00 GMT  
 auto-incrementing a primary key

You may want to look at a book entitled: "FoxPro: The Pros Talk" or
something to that effect. There's a class that a gentleman created called an
EDC (extended database container) that among other things, does an
auto-increment. It's available on a CD-ROM in the back of the book. It
extends the DBC to allow additional properties, methods, etc.

I think the gentleman's name was Ed something.

Quote:

>Hello all,

>Sorry, I'm a newbie to VFP 5.0 ...

>I'm wondering how to auto-increment a primary key field for every record

>I add in a table, and if it is possible to prefix this key with
>something like "tv_" followed by the value.

>Thanks very much in advance for your great help and greetings from
>Switzerland

>Rgis Piccand



Mon, 28 Aug 2000 03:00:00 GMT  
 auto-incrementing a primary key

This one?

The Pros Talk Microsoft Visual FoxPro 3
Author: Pinnacle Publishing
Retail Price: $49.95
Spree Price: $39.96
You Save: $9.99 (20%)
Weight (lb):  3.10
Publication Date: 1996
Dimension (in inches): 9.13x7.33x1.59
Binding: Quality paperback
Pages: 928
Publisher: Microsoft Press
Subject: COMPUTER TECHNOLOGY & SOFTWARE : Hypertext Systems
ISBN: 1572312335

Greg

Quote:

> You may want to look at a book entitled: "FoxPro: The Pros Talk" or
> something to that effect. There's a class that a gentleman created called an
> EDC (extended database container) that among other things, does an
> auto-increment. It's available on a CD-ROM in the back of the book. It
> extends the DBC to allow additional properties, methods, etc.

> I think the gentleman's name was Ed something.



Mon, 28 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Auto-incrementing a primary key field

2. auto-incrementing a primary key

3. Auto Incrementing Primary Key

4. auto-generating primary keys

5. Auto Increment Field

6. Auto Increment

7. Auto Increment Field

8. Auto-Incrementing

9. Auto Increment Field

10. Auto-Incremented field

11. Auto-increment Field in Foxpro

12. How to make an auto-incrementing index

 

 
Powered by phpBB® Forum Software