On 4 Apr 2011, at 6:01pm, Nico Williams wrote: > On Mon, Apr 4, 2011 at 11:25 AM, Simon Slavin <slav...@bigfraud.org> wrote: >> Probably not. Don't try to turn SQL into a procedural language. Do the >> SELECT that tells you whether the record exists and gives you the >> information you need if it does, then do whatever INSERTs you need to do. > > I agree with the first part. I don't agree with the second. SQL _is_ > a programming language. If you resort to using a procedural language > to do the things you don't know how to do in SQL then you're not > really meeting the spirit of your first recommendation. This is why I > like the INSERT ... SELECT ... WHERE > <condition-that-would-go-in-an-if-then-else> idiom: it's declarative, > and it uses SQL as a programming language with less glue needed from > the host language.
But he's combining two INSERTs into one. What I think he needs is first an INSERT OR FAIL to possibly add a new person, and then an INSERT ... SELECT which looks up that person's ID. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users