Hi everyone, I just stumbled about a problem with sqlite that I am not able to solve. I hope to find the most experienced sqlite users here, maybe you know of a solution :)
If I insert a record into a table with a primary key column id, Sqlite assigns a ROWID as outlined here http://www.sqlite.org/autoinc.html. However, I would like to assign a totally random rowid. While I can adjust the rowid with a trigger a la CREATE TRIGGER table_insert AFTER insert ON table BEGIN UPDATE table SET id=random() WHERE rowid=new.rowid; END; I don't find a way to get the id adjusted like this via last_inserted_row_id. I then tried to adjust the inserted id via fiddling with the SQLITE_SEQUENCE table (not without some nervous hesitation :). A quick test in the sqlite3 command line tool, however, showed that one can only increase the next automatically id, but not decrease it. Hence, no avail. Does anyone have an idea, whether or not it is possible either a) to adjust the id in a trigger and have the last_insert_row_id return the adjusted value, or b) to adjust the strategy how sqlite generates row ids for newly generated records. Any hint is greatly appreciated. Thank you, /eno _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users