"alp" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> I have to tables(TBL_OBJECTS, TBL_TAGS) and I want to use the ROWID
> of the last inserted row from table TBL_OBJECTS to insert a new row
> in TBL_TAGS table with the ID_OBJECT foreign key set to the ROWID
> value from the precedent table.
>
> INSERT INTO TBL_OBJECTS
>  (DATA,
>  PATH)
>  VALUES ('val1', 'val2');
>
>  INSERT INTO TBL_TAGS
>  (ID_TAG_TYPE,
>  ID_OBJECT,
>  TAG_DATA)
>  VALUES (1, 2, 'a'); --doesn't count what value is inserted for
> ID_OBJECT as it will be changed in the next statement

Why not just

INSERT INTO TBL_TAGS
  (ID_TAG_TYPE,
  ID_OBJECT,
  TAG_DATA)
  VALUES (1, last_insert_rowid(), 'a');

See http://sqlite.org/lang_corefunc.html

Igor Tandetnik 



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

Reply via email to