Hello Eugene, How about initally attempting the fetch and if that fails, do the insert? Since the results of a duplicate means you want the two additional blobs anyway.
Select so and so on empty results Insert so and so. C Friday, March 11, 2011, 9:15:14 AM, you wrote: EN> Hello EN> I am just beginning my thorn-ridden way up the steep slope with SQLite and EN> C++ to keep me company. And i am stuck at one point, so if you could help me EN> to continue it would be awsome. EN> I have a database contaning a table with a layout like this: EN> NAME PART1 PART2 EN> blob blob blob EN> blob blob blob EN> ... ... ... EN> I am thinking of creating it like: EN> CREATE TABLE points (NAME blob unique, PART1 blob, PART2 blob); EN> Then, in a loop, i will obtain new blob tuples and insert them in my table: EN> INSERT INTO points VALUES(?,?,?); // using prepare statement and bind EN> blob EN> Then comes a tricky bit: EN> 1) If there is a tuple with same NAME ( SQL error: column name is not EN> unique) already, EN> 2) I want to fetch its components PART1 and PART2 EN> SELECT PART1, PART2 FROM points WHERE NAME = ?; EN> // using prepare statement and bind blob EN> The problem is, i dont know how to *DETECT* a collision gracefully. EN> I first thought of looking at an error code, but i am not sure its a good EN> idea. Then EN> I heard somewhere about a thing called TRIGGERS, but still i am not sure, if EN> thats EN> the easiest way. EN> So, basically, how do you detect duplicates and handle them how you consider EN> appropriate? EN> Thanks, EN> Eugene EN> _______________________________________________ EN> sqlite-users mailing list EN> sqlite-users@sqlite.org EN> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users -- Best regards, Teg mailto:t...@djii.com _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users