On 05.03.2011, at 02:21, Simon Slavin wrote:

> 
> On 5 Mar 2011, at 1:18am, Enrico Thierbach wrote:
> 
>> I do have a working solution for synching my databases (with randomly 
>> generated ROWIDs). The problem I face
>> is that I cannot get the rowid of a newly created record to pass thru back 
>> into the application using last_insert_row_id.
> 
> I think you have no real reason to use rowid at all here.  Make a different 
> field called 'uniqueKey' or something, and use that for your random numbers.



Hi simon, hi list,

using a different field would break associations between tables. For example:

Assume we have tables a and b, and a join table as_to_bs. The a and b table 
both have a uniqueKey column, as you suggest, that will be set by a trigger.
If two database applications create a and b objects that are joined (e.g.

        a_rowid = INSERT INTO a VALUES("a")  
        b_rowid = INSERT INTO b VALUES("b") 
        INSERT INTO as_to_bs (a_id, b_id)

both databases would end up with (1, 1) entries in the as_to_bs table. Now I 
could merge the a and b tables quite fine. In this process, however, the 
entries in the a and b tables would be assigned new rowids. If I would then 
merge the as_to_bs tables the association between the newly merged objects in A 
and B would be lost. 

Remember: as the application should not know about this replication thingy it 
would still use the id or rowid to refer its object and not a uniqueKey column 
or something. 

So, the question remains: how can I either adjust the way rowids are 
automatically generated or adjust each specific rowid when a row is inserted 
and have this one returned in the last_row_id.

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

Reply via email to