Deleting hole row.....

Deleting hole row.....

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

when i delete a row i want to decrement the ID field.
example
let's say i have a table with those values
ID | name |
1 | Ivan |
2 | bojan |
3 | ranko |

and when i want to delete the second row, the third row to be decremented like this
ID | name |
1 | Ivan |
2 | ranko |

anyone know the command?



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Pridružio: 19 Jun 2007
  • Poruke: 33
  • Gde živiš: Grad Beograd

Well, It is not good solution to change ID. But if You have to do it, I will suggest You to make cascade trigger which will go through all tables where this key is used, and change id. It is very bad solution, but You asked for it.

And, here is pseudo code for changing ID.

FOR n := DeletedID+1 to RowCount
Id := Id - 1
ENDFOR



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

hmmmm that is for mysql?

I readed somewhere that i can use "pack" at the end of the statemant, but it's not working or i m not using in the right way.

Ko je trenutno na forumu
 

Ukupno su 1666 korisnika na forumu :: 67 registrovanih, 6 sakrivenih i 1593 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 20624 - dana 04 Apr 2026 04:18

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., AC-DC, blankspace, bobomicek, bojan1234, Boris90, BOXRR, carinko, celt, Chainsaw, cuvarkuca, dejan1972, Dimitrise93, Dioniss, Dixtrix, esx66, galerija, goxin, Hans Gajger, HogarStrashni, InzenjerBL, JK, jodzula, Khaless, Khalid ibn al-Walid, knutveliki, kulus, kybonacci, Laluvr, laurusri, Lazur_01, Mane88, Marko Marković, marre, marsi, Mcdado, mercedesamg, milos.cbr, Mldo, mocnijogurt, Moldovan, moldway, mrgud2025, nebidrag, nebojsag, nixos, nnovakis, nobutado, pceklic, peradetlić, Piani Jazzer, rodoljub, royst33, Sarmat, Sharpshooter, Solunac na steroidima, Srki98, sspp, Tandrkalo, tomo2, vathra, Velizar Laro, Wehicle, wizzardone, YFSS33, zillbg, Zmajac