Re: [SQL] feature request ?

2004-06-24 Thread Rosser Schwarz
On Fri, 25 Jun 2004 08:16:47 +0400, sad <[EMAIL PROTECTED]> wrote: > > Very simply, a boolean may have to values: true or false. It's also > > possible that it's not been set to anything (NULL). > really ? > what about (13 < NULL)::BOOL Per the semantics of NULL, 13 is neither greater than no

Re: [SQL] feature request ?

2004-06-24 Thread sad
> Very simply, a boolean may have to values: true or false. It's also > possible that it's not been set to anything (NULL). really ? what about (13 < NULL)::BOOL ---(end of broadcast)--- TIP 7: don't forget to increase your free space map sett

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Phil Endecott
Graham Leggett <[EMAIL PROTECTED]> wrote: > >>- Select the money column from the table > >>- Populate the new normalised table with each row containing > >> the value from the original money column > >>- Write the primary keys of the new rows in the normalised > >> table, back to a new column in

Re: [SQL] feature request ?

2004-06-24 Thread Geoffrey
Very simply, a boolean may have to values: true or false. It's also possible that it's not been set to anything (NULL). -- Until later, Geoffrey Registered Linux User #108567 Building secure systems in spite of Microsoft ---(end of broadcast)--

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Graham Leggett
Phil Endecott wrote: - Select the money column from the table - Populate the new normalised table with each row containing the value from the original money column - Write the primary keys of the new rows in the normalised table, back to a new column in the original table added for this purpose.

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Graham Leggett
Frank Bax wrote: Do all three steps in one command: create table newtable as (select key1, key2, money from oldtable); How would I put the primary key of each row in newtable back into oldtable? Also, newtable already exists and contains data - I need to add normalised data to an already partiall

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Frank Bax
At 02:51 PM 6/24/04, Graham Leggett wrote: I have an existing table containing a column in it containing a money value. I would like to normalise this column into a separate table, as the money value is to be expanded to contain a tax value, etc. I have been trying to find a SQL query that will

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Phil Endecott
Graham Leggett wrote: > I have an existing table containing a column in it containing > a money value. I would like to normalise this column into a > separate table, as the money value is to be expanded to contain > a tax value, etc. > > I have been trying to find a SQL query that will do the > fo

[SQL] Question about a CIDR based query

2004-06-24 Thread Georgos Siganos
Hello, Consider that I have the following table: Create Table tmp(             route_id     int    NOT NULL,             route         cidr   NOT NULL,             Data         varchar(100) NOT NULL) The table contains ~40,000 routes and I have an index on route. The query I am interested in is

Re: [SQL] feature request ?

2004-06-24 Thread Andrew Sullivan
On Thu, Jun 24, 2004 at 12:32:59PM -0500, Jaime Casanova wrote: > > Why not disallow the ability of boolean fields to be null? Why not do it yourself? That's what the NOT NULL constraint is for. A -- Andrew Sullivan | [EMAIL PROTECTED] I remember when computers were frustrating because they

[SQL] Normalising an existing table - how?

2004-06-24 Thread Graham Leggett
Hi all, I have an existing table containing a column in it containing a money value. I would like to normalise this column into a separate table, as the money value is to be expanded to contain a tax value, etc. I have been trying to find a SQL query that will do the following: - Select the mone

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, Bruno Wolff III wrote: > On Thu, Jun 24, 2004 at 07:34:18 -0700, > Stephan Szabo <[EMAIL PROTECTED]> wrote: > > > > I was thinking that something like Cs switch might work. There's still a > > question of the keywords because I don't like reusing case, but maybe > > somethi

Re: [SQL] feature request ?

2004-06-24 Thread Radu-Adrian Popescu
Bruno Wolff III wrote: There already is a syntax like this. You can do: CASE boolean_expression WHEN TRUE THEN whatever WHEN FALSE THEN whatever ELSE whatever END Besides, sad, there's no such thing as a tri-valued boolean. You either have a boolean(with a true/false value) or a NULL, which i

Re: [SQL] feature request ?

2004-06-24 Thread Bruno Wolff III
On Thu, Jun 24, 2004 at 07:34:18 -0700, Stephan Szabo <[EMAIL PROTECTED]> wrote: > > I was thinking that something like Cs switch might work. There's still a > question of the keywords because I don't like reusing case, but maybe > something of the general form: > case foo > is true > is fa

Re: [SQL] feature request ?

2004-06-24 Thread Jaime Casanova
Hi all,   Tri-valued boolean?? that's not against boolean concept?? i'm not saying that SQL is wrong nor Postgresql has to go beyond standard, i'm just trying to understand this stuff.   Why not disallow the ability of boolean fields to be null?   thanx in advance,   Jaime CasanovaMichael Glaesema

Re: [SQL] feature request ?

2004-06-24 Thread Michael Glaesemann
On Jun 24, 2004, at 6:39 PM, sad wrote: ...IF ELSEIF ELSE it's all clear but what about unequality of BOOL type possible value set and IF alternatives set In my opinion the short answer is NULL is here because of the SQL standard. The SQL standard does not specify any kind of "IF alternative" fo

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > then lots of currently perfectly correct > > programs break. If they're the same, then ELSE has different meanings > > depending on whether NULL is specified, and that's generally bad from an > > understanding the language standpoint. > > i've already thougth

Re: [SQL] feature request ?

2004-06-24 Thread sad
> then lots of currently perfectly correct > programs break. If they're the same, then ELSE has different meanings > depending on whether NULL is specified, and that's generally bad from an > understanding the language standpoint. i've already thougth on this new control structure needed but the

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > If you were to add a NULL block you'd have to deal with things > > like, if you only have a then and else, do you run the else on NULL or do > > you do nothing? If you do nothing, what if you want the null and else to > > be the same, do you add another way to

Re: [SQL] feature request ?

2004-06-24 Thread sad
> If you were to add a NULL block you'd have to deal with things > like, if you only have a then and else, do you run the else on NULL or do > you do nothing? If you do nothing, what if you want the null and else to > be the same, do you add another way to specify that? If you do the else, > the

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > I don't see what your point is. That SQL is wrong ? Or that SQL is not "C" > > ? Or that SQL is not a "programming language" ? > > Who said wrong ? who said SQL ? > > I thougth _WHY_ > the IF control structure has exactly two alternate blocks ? > a BOOLEAN expre

Re: [SQL] feature request ?

2004-06-24 Thread sad
On Thursday 24 June 2004 14:32, Alexander M. Pravking wrote: > On Thu, Jun 24, 2004 at 11:04:15AM +0400, sad wrote: > > Now you treat NULLs as false. > > Nope. NULL is neither true, nor false. It's "unknown", or "undefined". > > fduch=# SELECT 1 WHERE NULL::boolean; > ?column? > -- > (0 ro

Re: [SQL] feature request ?

2004-06-24 Thread Alexander M. Pravking
On Thu, Jun 24, 2004 at 11:04:15AM +0400, sad wrote: > Now you treat NULLs as false. Nope. NULL is neither true, nor false. It's "unknown", or "undefined". fduch=# SELECT 1 WHERE NULL::boolean; ?column? -- (0 rows) fduch=# SELECT 1 WHERE NOT NULL::boolean; ?column? -- (0 rows)

Re: [SQL] feature request ?

2004-06-24 Thread sad
...IF ELSEIF ELSE it's all clear but what about unequality of BOOL type possible value set and IF alternatives set ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] feature request ?

2004-06-24 Thread Iain
> > IF foo IS NULL > > THEN ... > > ELSIF foo > > THEN ... > > ELSE ... > > END IF; > > here the foo expression woll be executed twice if you can use an immutable or stable function then the overhead would be minimal as the system knows that it doesn't need to re-evaluate it. regards Iain

Re: [SQL] feature request ?

2004-06-24 Thread Michael Glaesemann
On Jun 24, 2004, at 1:49 PM, sad wrote: On Thursday 24 June 2004 09:32, Michael Glaesemann wrote: Creating a new control structure to do handle this seems odd. However, one could easily have the same effect using a nested if. Using the pl/pgsql ELSIF construct, it's pretty straightforward. IF foo I

Re: [SQL] feature request ?

2004-06-24 Thread sad
> I don't see what your point is. That SQL is wrong ? Or that SQL is not "C" > ? Or that SQL is not a "programming language" ? Who said wrong ? who said SQL ? I thougth _WHY_ the IF control structure has exactly two alternate blocks ? a BOOLEAN expression has exactly two possible values, that's

Re: [SQL] feature request ?

2004-06-24 Thread Gregory S. Williamson
Programming languages, perhaps, but clearly not uncommon in SQL ... Informix certainly allows a column to be of type boolean but with a value of NULL for given rows (unless precluded by a not-null constraint). Should we question integers, which can be positive, negative, or -- gasp ! -- NULL ?