On Oct 14, 2011, at 10:23 AM, James Hartley wrote:

> When dealing with tables with foreign constraints, how can the value of a
> recently inserted primary key be propagated to multiple child tables?  Is
> there a way to save the value of last_insert_rowid() as a SQL statement?

Sure.

insert  
into      my_very_own_last_insert_rowid
            (
              my_last_insert_rowid
           )
values ( 
                last_insert_rowid()
             )

> 
> Lastly, shouldn't the last INSERT statement below fail given that a row in
> the parent table doesn't exist with a parent_id = 2?


Sure.

PRAGMA foreign_keys = ON

http://www.sqlite.org/foreignkeys.html#fk_enable
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to