On Wed, 09 Feb 2011 17:54:37 -0500, Igor Tandetnik <itandet...@mvps.org> wrote:
> On 2/9/2011 5:49 PM, Jim Wilcoxson wrote: >> I assumed you could generate k in a procedural language outside of SQL, >> but >> if you want to do this purely in SQL, I think you can just say: >> >> create table t(k int primary key) >> insert into t values (min(?,?)<<32 | max(?,?)) >> >> and bind i,j,i,j to the parameters. > > Or make it > > insert into t values (min(:first,:second)<<32 | max(:first,:second)) > > and bind two parameters like you always did. If the order of (i, j) versus (j, i) is unimportant, then this is superior on most points to my corrected bit-XOR design. Normalizing away that order may be desired, so discarding it could be an advantage. But the XOR preserves that order, and that order may be part of the data; so it really depends on application requirements. And the XOR could also be done in pure SQL with SQLite patched to have a ^ operator. Due credit: I of course cribbed from the quoted idea to correct my previous error. Very truly, Samuel Adam ◊ <http://certifound.com/> 763 Montgomery Road ◊ Hillsborough, NJ 08844-1304 ◊ United States Legal advice from a non-lawyer: “If you are sued, don’t do what the Supreme Court of New Jersey, its agents, and its officers did.” http://www.youtube.com/watch?v=iT2hEwBfU1g _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users