2009/12/10 Yuzem <naujnit...@gmail.com>:
>
> CREATE TABLE movies(id integer,title text,unique(id))
>
> Generally I have an unique id from imdb but some times the movie isn't
> available.
> I understand that there is a column called rowid that is the primary key.
> I would like to insert the rowid on the id column when I don't have an id
> for the movie.
>
> Example:
> insert into movies values(rowid,'title1');
>
> How can I do that?

create trigger moviesTrig after insert on movies when new.id is null
begin update movies set id=rowid where rowid=new.rowid; end;

and insert via:
insert into movies( title ) values( xxx );

But there is no guarantee that the new rowid will not clash with any
existing id...

>
>

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

Reply via email to