On Thu, 13 Jan 2011 08:30:05 +0300, Max Vlasov <max.vla...@gmail.com> wrote:
[...snip...] >Maybe I didn't explain fully my situation. Sorry If I repeat some things >already clarified, but it's also for Nicolas, who answered here too. > >It was about a single row change in an editable grid control (not some >random user query). So the user is at some row of this grid changing values >in the cells and making some 'apply" after changing. This apply ends with >final "Update table set value1=...,value2=... where rowid=..." and the >"rowid=" here because it's the best way to identify a row from the table for >deleting and updating. After that apply I want to allow user to repeat the >same steps (moving cursor from cell to cell, changing and pressing apply). >Everything is ok if rowid is unaffected by the cells change (I just have >full set of rowids for the whole table), but if some of cells represents the >aliased rowid, this row becomes invalid after the change and I no longer can >identify it for any next change. If I simply reread all the data (I don't >want to since sometimes it takes time, but let's assume), I still won't be >able to place the cursor at the changed row since with rowid changes it will >no longer point to a valid row. > >To Nikolas Williams: I'd be glad to forbid rowid changes, but they're from >virtually unknown aliased column. > >Max A suggestion (untested): Include a rowid column in your grid, but don't display it. The user would be able to edit the rowid alias, if any, but not the hidden rowid itself. Your table selects would look like SELECT ROWID,col1,col2,col3,... FROM atable WHERE ... ORDER BY ...; or even SELECT ROWID, FROM atable ... ; and the update would have: UPDATE atable SET .... WHERE ROWID=$hiddenvalueingrid; You would have to check with PRAGMA table_info(atable) whether or not the special name ROWID is used by a user defined column, and if so, use one of the other special names, i.e. _rowid_ or oid in your select and update statements. See also: http://www.sqlite.org/lang_createtable.html#rowid HTH -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users