Re: Select enumeration of intergers

From: paul c <toledobythesea_at_oohay.ac>
Date: Fri, 07 Jul 2006 18:57:53 GMT
Message-ID: <R8yrg.132061$IK3.128737_at_pd7tw1no>


vadimtro_at_gmail.com wrote:

> frebe73_at_gmail.com wrote:

>> I need to make a select statements according to this:
>>
>> select value
>> from all_integers
>> where value => 510 and value < 515
>>
>> The result should be:
>> 510
>> 511
>> 512
>> 513
>> 514
>>
>> Any idea how to define the view "all_integers"? I prefer a solution for
>> MySQL, but solution for other vendors would be appreciated too.
>> ...
> 
> Alas I can tell you anything but MySQL solution:
> Postgres: generate_series
> Db2 & SQL Server: recursive with
> Oracle: almost a dozen methods. The most succinct:
> select rownum from dual
> connect by rownum < 1000
> 

I saw some comments about this at
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:948366252775   which fascinated me, along the lines of "the definition is whatever the implementation does" (my words). No wonder there is a market for people who explain these products. Some years since I knew any SQL but I got a kick out of the exchange where Mikito said that UNION should be identical to OR and the Oracle 'oracle' gave an example where it's not.   This seemed to depend on SQL tables allowing duplicate rows.

Noticed a web page about Postgresql at
http://www.postgresql.org/docs/8.0/interactive/functions-srf.html that talked of producing a 'series of values' then went on to say when zero 'rows' are returned which made me unsure whether its authors have bothered to define exactly what they mean. Although I'm out-of-date on lots of topics, I found this bizarrely reassuring as it jibed with the almost nothing I learned talking with one of them some years ago.

It all made me wonder whether any of these products have a consistent definition of whatever they mean by 'table', let alone data type/domain.

The idea of 'rownum' makes some sense to me, even though in Oracle it seems to be about just positive integers, not zero and the negative ones. This is because I think it's reasonable for an implementation to define all relations as having some arbitrary type as a candidate key (ie., there's no law saying all tuples must have values manually entered by users). Sometimes I wonder about having an 'un-project' operator to materialize those.

One reason I like TTM is because it tries to define UNION a lot more precisely. It also would allow a way to define a kind of enumeration of a finite domain/data type in a way that none of these products seem to, eg. something like:

'all_integers <OR> <NOT> all_integers'

or '<NOT> (all_integers <AND> <NOT> all_integers). Too bad these products don't bother with exact definitions for their various features, makes the world more complicated/contradictory than it needs to be.

p Received on Fri Jul 07 2006 - 20:57:53 CEST

Original text of this message