On Thu, Jan 13, 2011 at 12:46 PM, Simon Slavin <slav...@bigfraud.org> wrote:

>
> On 13 Jan 2011, at 8:53am, Dan Kennedy wrote:
>
> > On 01/13/2011 02:31 AM, Max Vlasov wrote:
> >> Hi,
> >> for queries like UPDATE ... WHERE rowid=... one can in most cases reread
> the
> >> record (based on the rowid) and keep for example the cursor in the grid
> at
> >> the same record. But what if one of changed field is aliased to rowid,
> is
> >> there a way to find/track the changed record? In other words, how to
> find
> >> out the new rowid value for this record
> >
> >   CREATE TEMP TRIGGER...
>
> Genius.
>
> There appears to be no documentation on
>
> <http://www.sqlite.org/lang_createtrigger.html>
>
> about what the TEMP(ORARY) keyword does.
>
>

Simon, I also liked Dan's suggestion, now I'm trying to implement this, but
it seems that sqlite contains an interesting side effect or I don't know how
to call it.

if I create the following trigger

CREATE TEMP TRIGGER [UpdatedRowIdTrigger] AFTER UPDATE OF RowId ON TestTable
BEGIN
  UPDATE UpdatedRowId Set Value = new.rowid;
END;

...this update if fired only if I change rowid explicitly:
... UPDATE TestTable SET RowId=1236 WHERE RowId=1235
 and not if I change the aliased field
... UPDATE TestTable SET Id=1236 WHERE Id=1235

(checked in 3.7.4).

Maybe this functionality is rarely needed (googling "AFTER UPDATE OF RowId"
leads to a single page in the whole web) so probably nobody noticed this yet
or it does not work for temp triggers.

I hope I just did something wrong...

Max
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to