Michael Miller wrote: > I apologize if this is a double-post; I just got approved for the mailing > list, and I can't find the older message in the archives, so I'm reposting > it. > > I have a table with two columns, the first with a string and the second with > an integer. > > > Given a set of input strings, I want to perform this operation 50,000+ times > preferably in a single transaction: "If the string doesn't exist in the > table, create a new row with the string in the first column and 1 in the > second column. If the string does exist in the table, increment the second > column by 1" > > > What I am doing now is using the UPDATE statement, and checking (via C#) the > number of rows affected, and if this is zero, running an insert statement. > Doing this 50,000 times, without an encapsulating transaction, is an > expensive operation.
INSERT OR REPLACE > > > Is there any way to encapsulate this into SQL so that no outside interaction > in C# is needed to perform this operation, and so I can put 50,000 of these > into a transaction and commit all at once? > > > Thanks, > > Mike > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- Cyril SCETBON _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

