Pouziti autoincrementu

Josef Svoboda pepa.svob na mole.tiscali.cz
Středa Červen 18 11:14:36 CEST 2003


> No tak konkretne u MySQL to delam takhle:
> LOCK TABLES moje_tabulka WRITE, jina_tabulka WRITE;
> SELECT MAX(nejake_ciselne_pole)+1 FROM moje_tabulka;
> ...
> INSERT INTO moje_tabulka SET nejake_hodnoty;
> INSERT INTO jina_tabulka SET nejake_hodnoty;
> UNLOCK TABLES;
> Tim mam zarucene, ze behem zjistovani ID mi nikdo jiny do tablek nic
> nezapise, ***ale muze cist***. Takze pokud jiny thread chce nacist data
pro
> zobrazeni, nic u nebrani a pokud chce neco zapsat, tak proste ceka, dokud
ja
> neskoncim se zapisem a neUNLOCKnu.

Ale ted jsem se dival do online dokumentace a tam stoji toto:

If a thread obtains a READ lock on a table, that thread (and all
other threads) can only read from the table. If a thread obtains
a WRITE lock on a table, then only the thread holding the lock
can read from or write to the table. Other threads are blocked.

Josef Svoboda
--
Please remove animal when replying.
Pri odpovidani je treba znicit krtka.



Další informace o konferenci Test