Juan
|
Posted: 01/07/2005, 3:57 PM |
|
I am kind of toying around with sql. And I want to add an auto increment statement into the ID field of a contacts table:
INSERT INTO contacts (ID) VALUE (NULL)
Since I've never worked with sql before I'm not sure where to place the sql statement in cc.
I built a form with serveral data entry fields on it and I have the ID field hidden.
My thought was to see how this all works, enter data into the form, press the insert button, post the data to the db and at the same time generate the autonumber.
Can someone give me a little guidance.
Thanks,
Juan
|
|
|
mrachow
Posts: 509
|
Posted: 01/09/2005, 12:52 AM |
|
Simply INSERT a record without giving ID. The ID will created during insert.
Most of database systems allow inserting of autoincrement columns but you have to give a valid nonexisting value. So your inserting of null won't work anyway.
In some cases you would like to have the just generated ID back. Here the database systems differ. I think SQL Server for example is using a stored procedure to retrieve the key for you.
_________________
Best regards,
Michael |
|
|
|