At least for SQLite it appears to be. From the Update doc page (http://www.sqlite.org/lang_update.html):
"The modifications made to each row affected by an UPDATE statement are determined by the list of assignments following the SET keyword. Each assignment specifies a column name to the left of the equals sign and a scalar expression to the right. For each affected row, the named columns are set to the values found by evaluating the corresponding scalar expressions. If a single column-name appears more than once in the list of assignment expressions, all but the rightmost occurrence is ignored. Columns that do not appear in the list of assignments are left unmodified. The scalar expressions may refer to columns of the row being updated. In this case all scalar expressions are evaluated before any assignments are made." And in fact I rely on it behaving this way for in one place in my SQLite code and it seems to be working correctly. Peter ----- Original Message ---- > From: skywind mailing lists <[email protected]> > To: General Discussion of SQLite Database <[email protected]> > Sent: Tue, May 7, 2013 10:46:42 AM > Subject: Re: [sqlite] Update statement > > Hi, > > my question is: is it guaranteed that it works? > > Regards, > Hartwig > > Am 07.05.2013 um 03:24 schrieb James K. Lowden: > > > On Mon, 6 May 2013 23:53:40 +0100 > > Simon Slavin <[email protected]> wrote: > > > >>> How do I create this kind of update statement? > >>> > >>> UPDATE T SET a=0.5*(a+b), b=0.5*(b-a); > >>> > >>> The RHS should always be used with the values of a and b before the > >>> assignment. > >>> > >>> I think that the result of this kind of statement is undefined, or? > >> > >> No need to worry, it will work the way you want it to work: > >> > >> The row is read. > >> The new values are calculated. > >> The new values are written to the database. > > ... > >> That was a terrible description. > > > > Actually that's not a bad approximation of what happens. Here's a > > simpler example: > > > > sqlite> create table t(a int, b int); > > sqlite> insert into t values (1,2); > > sqlite> select * from t; > > a b > > ---------- ---------- > > 1 2 > > sqlite> update t set a=b, b=a; -- Et Voila! > > sqlite> select * from t; > > a b > > ---------- ---------- > > 2 1 > > > > There is no "RHS". The syntax and semantics of SQL are its own; they > > cannot be extrapolated from other languages. > > I know but everybody knows what I meant, or? And its a quite brief description. > > > > > --jkl > > _______________________________________________ > > sqlite-users mailing list > > [email protected] > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

