[ic] Creating a Unique Primary Key

Marcel Montes marcel@multimake.com
Wed, 29 Nov 2000 16:40:49 -0300


--------------546335502E81AA547264100E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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).

> MySQL AUTO_INCREMENT function in the mysql data structure, and also
> specified it in the table.mysql file. But this was not working properly, So
> I figured it would be best to create a unique key in the form, right before
> inserting the row. Is there a way for me to check the previous record
> primary key value and add 1 to it? I remember reading it somewhere but I
> can't seem to find it.
>
> Any ideas?
>
> Thanks,
>
> Houman A.
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@www.minivend.com
> http://www.minivend.com/mailman/listinfo/interchange-users

if what you need is to add a record on the table that autoincrements the
primary key.
then it would be something like this on sql:
mysql> CREATE TABLE tbl_mytable (id INT PRIMARY KEY AUTO_INCREMENT, username
VARCHAR(20) NOT NULL, date DATE NOT NULL ....);

then:

mysql> INSERT INTO tbl_mytable (username, date) VALUES ("Houman Akhavan",
"2000-11-29");

this way, the indexed "id" field of tbl_mytable is generated by adding to 1 to
the last record's "id" field.
PD: when you modified table.mysql... did you restart the interchange daemon?

--
 Marcel Montes [marcel(at)multimake(dot)com] - Programmer
Documentation is like sex: it it's good, it's good, if it's
bad, is better than nothing...
-------------------------- EOF ----------------------------



--------------546335502E81AA547264100E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
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).
MySQL AUTO_INCREMENT function in the mysql data structure, and also
specified it in the table.mysql file. But this was not working properly, So
I figured it would be best to create a unique key in the form, right before
inserting the row. Is there a way for me to check the previous record
primary key value and add 1 to it? I remember reading it somewhere but I
can't seem to find it.

Any ideas?

Thanks,

Houman A.

_______________________________________________
Interchange-users mailing list
Interchange-users@www.minivend.com
http://www.minivend.com/mailman/listinfo/interchange-users

if what you need is to add a record on the table that autoincrements the primary key.
then it would be something like this on sql:
mysql> CREATE TABLE tbl_mytable (id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(20) NOT NULL, date DATE NOT NULL ....);

then:

mysql> INSERT INTO tbl_mytable (username, date) VALUES ("Houman Akhavan", "2000-11-29");

this way, the indexed "id" field of tbl_mytable is generated by adding to 1 to the last record's "id" field.
PD: when you modified table.mysql... did you restart the interchange daemon?

-- 
 Marcel Montes [marcel(at)multimake(dot)com] - Programmer  
Documentation is like sex: it it's good, it's good, if it's
bad, is better than nothing...
-------------------------- EOF ----------------------------
  --------------546335502E81AA547264100E--