Jean-Christophe Deschamps wrote:
> I'm trying to determine if a Range(from, to) function can be made as an 
> extension function.
> 
> Its effect would be to expand, for instance, range(1, 5) into (1, 2, 3, 
> 4, 5) for use in constructs similar to
>           select some_scalar_function(i) where i in range(1, 5);
> without having to build a table holding integers 1..5
> 
> I don't see how that's possible, but maybe someone with better internal 
> knowledge can advise.

Wouldn't it make more sense for "i in 1..5" to expand to "i >= 1 and i <= 5"?

Then it would also work for ordered types that aren't ordinal, such as 
rationals 
and strings and blobs and dates etc, and it would work for very large ranges, 
since there's no conceptual need to generate all the individual values.

Of course, you'd want to support all 4 variants: 1..5, 1..^5, 1^..5, 1^..^5, 
where a ^ means exclude that endpoint and its absence means include.

This is more flexible than SQL's BETWEEN, which I believe only covers one of 
those 4 options.

-- Darren Duncan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to