[ic] Creating a Unique Primary Key

Mike Heins mikeh@minivend.com
Wed, 29 Nov 2000 14:56:01 -0500


Quoting Marcel Montes (marcel@multimake.com):
> Houman... your text is a little confusing but here's what I think I catch:
> 
> Houman Akhavan wrote:
> 
> > I am running IC 4.6, MySQL Backend.
> >
> > I have created a table and a IC form that collects user input and stores it
> > in a MySQL table. Everytime someone fills out a form I need to create a
> > primary key to properly input the form data into the table. I tried the
> 
> On MySQL there's ONLY one primary key by table and as far as I know this has
> to be defined at table creation time. (for the primary index, not other
> indexes).

If you want something database-independent, then you can just do:

[seti the_key][counter][/seti]

Then reference the number in the form as:

	[scratch the_key]

(In earlier mvends, that would be [fcounter], usually in there somewhere).

That will of course cause you to have non-sequential keys when people
enter the form but don't submit, but that shouldn't be any problem. As
long as you don't remove etc/counter, you won't have any problem.

-- 
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
 -- Winston Churchill