Re: [SQL] filtering

2004-12-11 Thread Bruno Wolff III
On Thu, Dec 09, 2004 at 10:25:25 -0500, "Kevin B." <[EMAIL PROTECTED]> wrote: > Hi, > > I have a 14 million row table with one index on two fields one is a varchar > the other is a date. The combination of the two makes the row unique. > > Data > - > name date... other fie

Re: [SQL] replacing mysql enum

2004-12-11 Thread Josh Berkus
Kenneth, > i translated this as: > > field varchar(2) check (field in (null,'a','b','c')), While this isn't the question you asked, might I encourage you to use DOMAINs instead? I.e.: CREATE DOMAIN abc_col AS TEXT CHECK VALUE IN ( 'a', 'b', 'c' ); Then you declare the table as: tabl

Re: [SQL] replacing mysql enum

2004-12-11 Thread Tom Lane
Ian Barwick <[EMAIL PROTECTED]> writes: > (Oddly enough, putting the NULL in the CHECK constraint seems > to make the constraint worthless: > test=> create table consttest (field varchar(2) check (field in > (null, 'a','b','c'))); > CREATE TABLE > test=> insert into consttest values ('xx'); > INSE

Re: [SQL] replacing mysql enum

2004-12-11 Thread Greg Stark
Ian Barwick <[EMAIL PROTECTED]> writes: > What I still don't quite understand is why IN in a CHECK context is > handled differently to say: select 1 where 'x' in (null,'a','b','c') ? > This could be a bit of a gotcha for anyone constructing a constraint > similar to the original poster's and not

Re: [SQL] Cast NULL into Timestamp?

2004-12-11 Thread Frank Bax
At 12:11 AM 12/11/04, Josh Berkus wrote: Wei, > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_relevant_table; I don't think you're reporting the error exactly as it happened. Try cutting and pasting your actual PSQL session into your e-mail. Perhaps

Re: [SQL] replacing mysql enum

2004-12-11 Thread Ian Barwick
On Sat, 11 Dec 2004 07:47:51 -0800 (PST), Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Sat, 11 Dec 2004, Ian Barwick wrote: > > > (Oddly enough, putting the NULL in the CHECK constraint seems > > to make the constraint worthless: > > test=> create table consttest (field varchar(2) check (field i

Re: [SQL] replacing mysql enum

2004-12-11 Thread Stephan Szabo
On Sat, 11 Dec 2004, Rod Taylor wrote: > On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote: > > On Sat, 11 Dec 2004, Ian Barwick wrote: > > > > > (Oddly enough, putting the NULL in the CHECK constraint seems > > > to make the constraint worthless: > > > test=> create table consttest (field v

Re: [SQL] replacing mysql enum

2004-12-11 Thread Rod Taylor
On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote: > On Sat, 11 Dec 2004, Ian Barwick wrote: > > > (Oddly enough, putting the NULL in the CHECK constraint seems > > to make the constraint worthless: > > test=> create table consttest (field varchar(2) check (field in > > (null, 'a','b','c')))

Re: [SQL] replacing mysql enum

2004-12-11 Thread Stephan Szabo
On Sat, 11 Dec 2004, Ian Barwick wrote: > (Oddly enough, putting the NULL in the CHECK constraint seems > to make the constraint worthless: > test=> create table consttest (field varchar(2) check (field in > (null, 'a','b','c'))); > CREATE TABLE > test=> insert into consttest values ('xx'); > INS

Re: [SQL] [GENERAL] Query is not using index when it should

2004-12-11 Thread Tomas Skäre
Stephan Szabo <[EMAIL PROTECTED]> writes: > On Fri, 10 Dec 2004, Tomas [iso-8859-1] Skäre wrote: > > > I have a table that looks like this: > > > > Table "public.cjm_object" > > Column | Type| Modifiers > > ---+---+--- > > timestamp | bi

Re: [SQL] replacing mysql enum

2004-12-11 Thread Ian Barwick
On Sat, 11 Dec 2004 10:30:55 +0530, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > hi, > > from mysql: > > field enum('a','b','c') default null, > > i translated this as: > > field varchar(2) check (field in (null,'a','b','c')), > > is it necessary to put the 'null' in the check condition? if

Re: [SQL] Create Calendar

2004-12-11 Thread Joe Conway
Muhyiddin A.M Hayat wrote: How to create Calendar using Function/View. For example i would like to display date 2004-12-01 to 2004-12-20. date -- 2004-12-01 2004-12-02 2004-12-03 2004-12-04 2004-12-05 .. .. 2004-12-20 -- Use in Postgres 7.4.x and earlie

[SQL] PREPARED STATEMENT

2004-12-11 Thread NosyMan
Hi there, I want to know that is a posibillity to test if a statement is prepared in PL/PgSQL. I have create a function: . PREPARE PSTAT_SAVE_record(INTEGER, INTEGER, DATE, VARCHAR) AS INSERT INTO table VALUES($1, $2, $3, $4); . When I try to execute it second time I got an er