deleting autoincrement field.

jaya

Member
Joined
May 5, 2005
Messages
15
Programming Experience
Beginner
in my form i have one autoincrement field. and i am trying to remove one row.
my query is
if i delete any row in the middle of the record ,then the autoincrement field should automatically adjust
ex.
if i delete 3 record ,then the record with id 4 should be now 3 .
thks
 
You would probably have to go through each row and change the id. Can I ask why you would want to do this though? It seems a bit strange to me
 
deleting an autoincrement field.

changing each row manually is meaningless.changing the id programatically is better.y i want to delete the row is i can explain u by taking an example.
if we go for online shopping,we order some thing and assume that there the itemno. is an autoincrement field.after a while,i want to cancel one item in between ,then all the items after that should be adjusted automatically.(i mean the itemno) field.hope i am clear any queries and suggestions,welcome
thk u
levyuk said:
You would probably have to go through each row and change the id. Can I ask why you would want to do this though? It seems a bit strange to me
 
Correct me if I'm wrong, but if a field is autoincremented then won't its value be set by the database when you commit the new row? Isn't that what the auto part means? I have, at times, used dummy values for the autoincremented keys of my rows so that I can identify them in code before they are committed. This doesn't mean that those key values will be the actual values assign though. Just use whatever integer values you want before the row is committed and the database should take care of the actual key assignment when the row is inserted.
 
thks for ur response but i couldnt get u

in my form ,my requirement is ,i keep one auto inc field and if i delete any row in betn the next rows in the database should be adjusted automatically.
thk u
jmcilhinney said:
Correct me if I'm wrong, but if a field is autoincremented then won't its value be set by the database when you commit the new row? Isn't that what the auto part means? I have, at times, used dummy values for the autoincremented keys of my rows so that I can identify them in code before they are committed. This doesn't mean that those key values will be the actual values assign though. Just use whatever integer values you want before the row is committed and the database should take care of the actual key assignment when the row is inserted.
 
You say that you have an autoincremented field. This means that the database itself sets the field value when you insert the row. If you are using a shopping cart, you will presumably just have each row in a local DataTable until the user commits their purchase. It doesn't matter what value you put in the field while the user is making up their mind because the database will still assign the actual field value when the new row is committed. Otherwise, its not an autoincremented field at all. It's a manually incremented field.
 
Back
Top