Re: [SQL] Calendar Scripts - Quite a complex one

2004-01-08 Thread Chris Travers
Hi Kumar and others;

I have never worked with functions to return references to cursors.  Is
there a reason why it has to be done this way rather than returning a setof
appointments?

In that case:
create function app_today returns setof appointment (date) as '
declare
new_appoint appointment;
appoint_recur recurrance
begin
for appointment in [SELECT query]
loop
-- do calculations
if [condition] then
return next;
end if;
end loop;
end;
' language plpgsql;

Note that the function is off my head and not even guaranteed to be exactly
what you need.

Best Wishes,
Chris Travers

- Original Message -
From: "Kumar" <[EMAIL PROTECTED]>
To: "Chris Travers" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; "Peter
Eisentraut" <[EMAIL PROTECTED]>; "psql" <[EMAIL PROTECTED]>
Sent: Wednesday, January 07, 2004 7:39 PM
Subject: Re: [SQL] Calendar Scripts - Quite a complex one


> Hi,
> yes yes. U understood in a very correct way, as i have 2 tables -
> appointments and recurrences. And we are not gonna use PHP.
>
> For future dates, I am not gonna populate, instead I am gonna check for
the
> recurrences tables for ever appointments and based on the conditions, I am
> gonna say how many time that appointment recure in that month and the
> timestamp.
>
> To process that I have get all the appointment data and its recurrence
> pattern data into the cursor. Is there a way to get the records one by one
> from the cursor and calculate it patterns.
>
> CREATE OR REPLACE FUNCTION crm.fn_calendar_daily_activities(timestamp)
>   RETURNS refcursor AS
> 'DECLARE
>  cal_daily_date ALIAS FOR $1;
>  ref  REFCURSOR;
>
> BEGIN
>  OPEN ref FOR
>  SELECT 
>
>  RETURN ref;
>
> END;'
> LANGUAGE 'plpgsql' VOLATILE;
>
> How to open the cursor here so that I could check its  recurrences
pattern.
>
> Please shed some light.
>
> Regards
> kumar
>
> - Original Message -
> From: "Chris Travers" <[EMAIL PROTECTED]>
> To: "Kumar" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; "Peter Eisentraut"
> <[EMAIL PROTECTED]>; "psql" <[EMAIL PROTECTED]>
> Sent: Wednesday, January 07, 2004 1:19 PM
> Subject: Re: [SQL] Calendar Scripts - Quite a complex one
>
>
> > Hi all;
> >
> > If I understand Kumar's post correctly, he is having some question
> relating
> > to the issue of even recurrance.  I would highly suggest reading the
> > ICalendar RFC (RFC 2445) as it has some interesting ideas on the
subject.
> > HERMES (my app with appointment/calendar functionality) doesn't yet
> support
> > appointment recurrance, and I have not formalized my approach to this.
> > However, here is the general approach I have been looking at:
> >
> > 1: Have a separate table of recurrance rules (1:1 with appointments) or
> have
> > a recurrance datatype.
> >
> > 2: Build some functions to calculate dates and times when the
appointment
> > would recurr.  You can also have a "Recur Until" field so you can limit
> your
> > searches this way.
> >
> > 3:  Use a view to find recurring appointments on any given day.
> >
> > This avoids a very nasty problem in the prepopulation approach-- that of
a
> > cancelled recurring meeting.  How do you cancel ALL appropriate
instances
> of
> > the meeting while leaving those that occured in the past available for
> > records?
> >
> > Kumar-- if you are working with PHP, I would be happy to work with you
in
> > this endevor so that the same functionality can exist in my open source
> > (GPL'd) application.  I think that the source for this would likely be
one
> > of those things that might be best LGPL'd if added to my app.
> >
> > Best Wishes,
> > Chris Travers
> >
> > - Original Message -
> > From: "Kumar" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>; "Peter Eisentraut" <[EMAIL PROTECTED]>; "psql"
> > <[EMAIL PROTECTED]>
> > Sent: Wednesday, January 07, 2004 1:06 PM
> > Subject: Re: [SQL] Calendar Scripts - Quite a complex one
> >
> >
> > > Hi,
> > >
> > > The complexity comes while scheduling the appointments. Let us say, I
> have
> > > scheduled so many meetings in my calendar of various schedules like
> daily,
> > 3
> > > days once, weekly, bi weekly. monthly, bi monthly, etc.
> > >
> > > While I open the calendar for end of this year (say Dec 2004), I need
to
> > > show those meetings in my calendar, but I have data until Jan 2004.
> > >
> > > What is the best way to show it. Populating the records from Jan 2004
to
> > Dec
> > > 2004 in the pgsql function and display it in the calendar, or just
write
> a
> > > query to generate temporary records only for that Dec 2004 and not
> storing
> > > them at the database.
> > >
> > > Please shed some idea.
> > >
> > > Regards
> > > Kumar
> > >
> > > - Original Message -
> > > From: "Josh Berkus" <[EMAIL PROTECTED]>
> > > To: "Peter Eisentraut" <[EMAIL PROTECTED]>; "Kumar"
<[EMAIL PROTECTED]>;
> > > "psql" <[EMAIL PROTECTED]>
> > > Sent: Wednesday, January 07, 2004 3:43 AM
> > > Subject:

[SQL] Start-up problems

2004-01-08 Thread beyaRecords - The home Urban music
I am running postgresql 7.4.1 on OS X 10.3 and am having to manually 
start-up postgresql using /usr/local/pgsql/bin/postmaster -i -D 
/usr/local/pgsql/data.

Is there a script available which will enable me to automate this 
process, so that postgres loads up at startup?

Uzo

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [SQL] Start-up problems

2004-01-08 Thread Johannes Lochmann
On Thursday 08 January 2004 13:59, beyaRecords - The home Urban music wrote:
> I am running postgresql 7.4.1 on OS X 10.3 and am having to manually
> start-up postgresql using /usr/local/pgsql/bin/postmaster -i -D
> /usr/local/pgsql/data.
>
> Is there a script available which will enable me to automate this
> process, so that postgres loads up at startup?

pg_ctl  start

HTH

Johannes

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [SQL] Start-up problems

2004-01-08 Thread Kaloyan Iliev Iliev
Look at /etc/

beyaRecords - The home Urban music wrote:

Kaloyan,
thanks for reply. Still finding my way around the unix environment so 
could you tell me where the file you mention is situated?
On 8 Jan 2004, at 13:24, Kaloyan Iliev Iliev wrote:

This is what I have in my rc.local on FreeBSD:

su pgsql -c "/usr/local/bin/pg_ctl -D /usr/local/pgsql/data -o -i -l 
/usr/local/pgsql/logfile start
"

beyaRecords - The home Urban music wrote:

I am running postgresql 7.4.1 on OS X 10.3 and am having to manually 
start-up postgresql using /usr/local/pgsql/bin/postmaster -i -D 
/usr/local/pgsql/data.

Is there a script available which will enable me to automate this 
process, so that postgres loads up at startup?

Uzo

---(end of 
broadcast)---
TIP 1: subscribe and unsubscribe commands go to 
[EMAIL PROTECTED]







---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


[SQL] COPY command

2004-01-08 Thread azwa



Hi,


  i try to load a file into temporary table but it gives me an error . do u have any idea/solutions ??  the command that i've running as below :


    dwnc=# copy biosadm.custdo_temp
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
dwnc-# WITH DELIMITER ',' ;

ERROR:  copy: line 141, Extra data after last expected column

FYI, my file was in comma delimiter type (csv) . My table structure as following :

    dwnc-# \dbiosadm.custdo_temp
         Table "biosadm.custdo_temp"
  Column  |         Type          | Modifiers
--+---+---
 dono     | character varying(13) |
 dodate   | date                  |
 custname | character varying(70) |
 custlo   | character varying(40) |
 attnto   | character varying(80) |


Please guide me . thanks

[SQL] grouping by date

2004-01-08 Thread teknokrat
How can I group by date given a timestamp column?

thanks

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
 joining column's datatypes do not match


Re: [SQL] unix time -> timestamp

2004-01-08 Thread boyd
In article <[EMAIL PROTECTED]>,
 boyd <[EMAIL PROTECTED]> wrote:

> I'm pretty sure in 7.0 postgres, (but I may be wrong) you could insert 
> directly from a perl script something like this:
>$time = time; # this gives epoch seconds
>$sql = "insert into mytable values(..., timestamp($time), ...) ";
> 
> And then the $sql string would run with the DBI call, etc.  
> 
> When I tried the same script on 7.2, it would not take it.  I think I 
> once found another way to do it in 7.2.  Of course, I can create a 
> formatted string in perl that will be accepted by the insert, but it 
> seems inefficient to have to do it through strings. 
> 
> Boyd tbmooreATbealenetDOTcom

Sorry - five minutes later, I found it -

You just use abstime as the function to convert, as in:

   "insert into mytable values(..., abstime($time), ...) ";

 Boyd tbmooreATbealenetDOTcom


---(end of broadcast)---
TIP 8: explain analyze is your friend


[SQL] COPY command

2004-01-08 Thread azwa


Hi,


  i try to load a file into temporary table but it gives me an error . do u
have any idea/solutions ??  the command that i've running as below :


dwnc=# copy biosadm.custdo_temp
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
dwnc-# WITH DELIMITER ',' ;

ERROR:  copy: line 141, Extra data after last expected column

FYI, my file was in comma delimiter type (csv) . My table structure as
following :

dwnc-# \dbiosadm.custdo_temp
 Table "biosadm.custdo_temp"
  Column  | Type  | Modifiers
--+---+---
 dono | character varying(13) |
 dodate   | date  |
 custname | character varying(70) |
 custlo   | character varying(40) |
 attnto   | character varying(80) |


Please guide me . thanks


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] Different query results in psql and Perl DBI with Postgres 7.2.1

2004-01-08 Thread boyd
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Brendan LeFebvre) wrote:

> I have a script that updates one record in a PostgreSQL 7.2.1 database
> through the Perl DBI.
> 

> Where do I even begin to attempt a diagnosis?

Here is the output from a script I ran with no problems under 7.2.1, 
followed by the script:

OUTPUT
-
DB info : PostgreSQL 7.2.1
 Table "item"
 Column  |  Type   | Modifiers 
-+-+---
 item_id | integer | 
 status  | text| 

doing query < TRUNCATE item > 
-1 rows affected
doing query < INSERT INTO item VALUES(1129832,'BACKORDER') > 
1 rows affected
doing query < INSERT INTO item VALUES(1130081,'OUTOFSTOCK') > 
1 rows affected
doing query < UPDATE item SET status='SOLD' WHERE item_id=1129832 > 
1 rows affected
doing query < UPDATE item SET status='STORE' WHERE item_id=1130081 > 
1 rows affected

SCRIPT
--
#!/usr/bin/perl -w

use strict;
use DBI;

our $DBH;
sub dienicely {
warn "$DBH->errstr";
$DBH->disconnect;
}

sub runquery {
my $sql = shift;
print "doing query < $sql > \n";
my $rows = $DBH->do($sql) or dienicely;
print "$rows rows affected\n";
}

$DBH = DBI->connect("dbi:Pg:dbname=boyd","","");
my $info = $DBH->get_info(17) .' '. $DBH->get_info(18);
$info =~ s/0//g; # the get_info adds extraneous '0' to the version number
print "DB info : $info\n";
print `psql -c '\\d item'`;

runquery("TRUNCATE item");

runquery( "INSERT INTO item VALUES(1129832,'BACKORDER')" );

runquery( "INSERT INTO item VALUES(1130081,'OUTOFSTOCK')" );

runquery( "UPDATE item SET status='SOLD' WHERE item_id=1129832" );

runquery( "UPDATE item SET status='STORE' WHERE item_id=1130081" );

$DBH->disconnect;

Hope that helps.
Boyd


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[SQL] question : the choice of the primary key.

2004-01-08 Thread Loeke
U have for example something like this

create table persons(
(id..),
surename ..,
familyname ..,
street ..,
..,
birthdate,..
)

a table containing the data of persons, each persons should of course be
present only once;
and one should still define a primary key,
there are two options now,
1.many people make an extra id field and choose this id field to be the
p-key,
but then the same person can be present twice in the table (with different
id fields), the id in itself has no real meaning
2.or u can choose the "natural" key for each person, lets say a name and the
birthdate of a person make that person unique, so lets make (the whole name
en the birthdate) the primary-key; but then if another table X wants to
refer this table of persons using a foreign key, this foreign key exists out
of 3 fields, which smells redundant

u have often this choice in determining the primary keys,

plz give me your opinions, options i overlooked or usefull comments.



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[SQL] Different query results in psql and Perl DBI with Postgres 7.2.1

2004-01-08 Thread Brendan LeFebvre
I have a script that updates one record in a PostgreSQL 7.2.1 database
through the Perl DBI.

Here is the output from my log, which outputs the query sent to the
DBI and the return value:

---

Update query: UPDATE item SET status='SOLD' WHERE item_id=1129832
1 rows affected.

Update query: UPDATE item SET status='STORE' WHERE item_id=1130081
0E0 rows affected.

---

In both cases, the target record exists without question, and in the
latter case, I receive the expected "UPDATE 1" when I execute the same
query from within psql.

Even more perplexing: the "0E0" occurs ONLY when setting status to
'STORE', and not 100% of the time. (though it happens far more often
than not.) It seems to operate in stretches, too: when I am getting
1-row updates back from the latter query type, it happens several
times in succession.

Where do I even begin to attempt a diagnosis?

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] question : the choice of the primary key.

2004-01-08 Thread Loeke
> 1.many people make an extra id field and choose this id field to be the
> p-key,
> but then the same person can be present twice in the table (with different
> id fields), the id in itself has no real meaning
> 2.or u can choose the "natural" key for each person, lets say a name and
the
> birthdate of a person make that person unique, so lets make (the whole
name
> en the birthdate) the primary-key; but then if another table X wants to
> refer this table of persons using a foreign key, this foreign key exists
out
> of 3 fields, which smells redundant

i solved it for now
using a p-key (the short id)
and a a-key (the natural key),
so integrity is ok and refences are short.

>
> u have often this choice in determining the primary keys,
>
> plz give me your opinions, options i overlooked or usefull comments.
>
>



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[SQL] unix time -> timestamp

2004-01-08 Thread boyd
I'm pretty sure in 7.0 postgres, (but I may be wrong) you could insert 
directly from a perl script something like this:
   $time = time; # this gives epoch seconds
   $sql = "insert into mytable values(..., timestamp($time), ...) ";

And then the $sql string would run with the DBI call, etc.  

When I tried the same script on 7.2, it would not take it.  I think I 
once found another way to do it in 7.2.  Of course, I can create a 
formatted string in perl that will be accepted by the insert, but it 
seems inefficient to have to do it through strings. 

Boyd tbmooreATbealenetDOTcom


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


[SQL] PostgreSQL Array Syntax

2004-01-08 Thread Evan Klinger
Good afternoon.

I am attempting to create a PHP script that inserts values into a 
PostgreSQL database, where some of the columns are two dimensional 
arrays. I read the docs and it says that array elements must be matched 
and that is what I am confused about. Does that mean that 
ARRAY[['eng_labs'], ['eng_labs', 'mst_labs', 'ics_labs']] is incorrect 
array syntax? If so, I am assuming that the way to correct it would be:
ARRAY[['eng_labs', '', ''], ['eng_labs', 'mst_labs', 'ics_labs']]. Thus, 
each multidimensional array must have values in place for the largest 
element, correct?

Thank you for your time
Evan Klinger
--
Evan Klinger
Network & Academic Computing Services
Research Computing Support
University of California, Irvine
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


[SQL] data loading

2004-01-08 Thread azwa



Hi,


  i try to load data from flat file (comma delimiter format) into temporary table . i use COPY command as below:

dwnc=# copy biosadm.custdo_temp 
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV' 
dwnc-# WITH DELIMITER ',' ; 

ERROR:  copy: line 141, Extra data after last expected column 


do u have any idea what causes the above error ???or is there any command can be used to load data as requested. tq 

[SQL] Date select question...

2004-01-08 Thread Lance Munslow
I have the following table:

 Table "public.test"
  Column   | Type | Modifiers
---+--+---
 test_date | date |

with the following data:

 test_date

 2004-10-31
 2004-11-01
(2 rows)

Why does the query:

select * from test where test_date between '20041001' and '20041101';

return TWO rows:

 test_date

 2004-10-31
 2004-11-01
(2 rows)

and the query:

 select * from test where test_date between 20041001 and 20041101;
 test_date

 2004-10-31
(1 row)

return just ONE row:

 test_date

 2004-10-31
(1 row)

regards,

Lance Munslow
Software Development
Travel Technology Systems Ltd

This Email may contain information of a confidential and/or privileged
nature.
The information transmitted is intended only for the benefit of the person
or entity to which it is addressed and must not be copied or forwarded
without the sender's express permission.
This Email does not reflect the views or opinions of Travel Technology
Systems Ltd.
This Email is without prejudice.
This Email does not constitute an agreement either explicitly or implicitly
with Travel Technology Systems Ltd.

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] COPY command

2004-01-08 Thread Gregory S. Williamson
This sounds as if the last character in each line might be a delimiter (a ",") which 
is standard for data unloaded from some sources; if this is the case try removing it 
and your data should load. Or you may have a comma in a character field and that is 
throwing off the count for the line in question ?

HTH,

Greg Williamson
DBA
GlobeXplorer LLC

-Original Message-
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent:   Tue 1/6/2004 10:19 PM
To: [EMAIL PROTECTED]
Cc: 
Subject:[SQL] COPY command

Hi,


  i try to load a file into temporary table but it gives me an error . do 
u have any idea/solutions ??  the command that i've running as below :


dwnc=# copy biosadm.custdo_temp
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
dwnc-# WITH DELIMITER ',' ;

ERROR:  copy: line 141, Extra data after last expected column

FYI, my file was in comma delimiter type (csv) . My table structure as 
following :

dwnc-# \dbiosadm.custdo_temp
 Table "biosadm.custdo_temp"
  Column  | Type  | Modifiers
--+---+---
 dono | character varying(13) |
 dodate   | date  |
 custname | character varying(70) |
 custlo   | character varying(40) |
 attnto   | character varying(80) |


Please guide me . thanks



---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] COPY command

2004-01-08 Thread azwa


Hi , 


yes now i can do the copy after replace comma delimiter with tab delimiter which is default copy with delimiter . btw  i've another 
question : how do we run the COPY command from file which has several null columns in each field.   
thanks. 

example : 

   dwnc=# copy biosadm.custinv_temp 
dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ; 
ERROR:  copy: line 1, Missing data for column "subsidiary"   


p/s: my subsidiary column has several null data. 







"Gregory S. Williamson" <[EMAIL PROTECTED]>

07:06 PM PST Yesterday


        To:        <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
        cc:        
        Subject:        RE: [SQL] COPY command


This sounds as if the last character in each line might be a delimiter (a ",") which is standard for data unloaded from some sources; if this is the case try removing it and your data should load. Or you may have a comma in a character field and that is throwing off the count for the line in question ?

HTH,

Greg Williamson
DBA
GlobeXplorer LLC

-Original Message-
From:                 [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent:                 Tue 1/6/2004 10:19 PM
To:                 [EMAIL PROTECTED]
Cc:                 
Subject:                 [SQL] COPY command

Hi,


  i try to load a file into temporary table but it gives me an error . do 
u have any idea/solutions ??  the command that i've running as below :


    dwnc=# copy biosadm.custdo_temp
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
dwnc-# WITH DELIMITER ',' ;

ERROR:  copy: line 141, Extra data after last expected column

FYI, my file was in comma delimiter type (csv) . My table structure as 
following :

    dwnc-# \dbiosadm.custdo_temp
         Table "biosadm.custdo_temp"
  Column  |         Type          | Modifiers
--+---+---
 dono     | character varying(13) |
 dodate   | date                  |
 custname | character varying(70) |
 custlo   | character varying(40) |
 attnto   | character varying(80) |


Please guide me . thanks





Re: [SQL] COPY command

2004-01-08 Thread Michael Glaesemann
On Jan 9, 2004, at 1:11 PM, [EMAIL PROTECTED] wrote:
how do we run the COPY command from file which has several null
columns in each field.  
thanks.
example :

   dwnc=# copy biosadm.custinv_temp
dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ;
ERROR:  copy: line 1, Missing data for column "subsidiary"  
Just like you specify the delimiter, you need to specify the value for 
NULL. For example, if your *.txt file has a line with a "missing" value 
(such as the space between 'bar' and 'foofoo')

foo	bar		foofoo	barbar

I usually use 'NULL' as NULL, so the line would be

foo	bar	NULL	foofoo	barbar

then use the COPY command with NULL AS 'NULL'

Check out the following link for detailed info on the COPY command:

HTH

Michael Glaesemann
grzm myrealbox com
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] grouping by date

2004-01-08 Thread Robert Creager
When grilled further on (Mon, 05 Jan 2004 17:14:26 +),
teknokrat <[EMAIL PROTECTED]> confessed:

> How can I group by date given a timestamp column?
> 

I just found this out this weekend.  Try 'date_trunc'.  Look at secion 9.8.2 of
the documentation.  I'm using something like:

SELECT date_trunc( 'hour', "when" ) AS "date" FROM readings GROUP BY "date";

Where "when" is my timestamp columnn.

Cheers,
Rob

-- 
 21:55:40 up 11 days, 11:46,  4 users,  load average: 2.09, 2.03, 2.01


pgp0.pgp
Description: PGP signature


Re: [SQL] Date select question...

2004-01-08 Thread Tom Lane
Lance Munslow <[EMAIL PROTECTED]> writes:
> [ why do these act differently: ]
> select * from test where test_date between '20041001' and '20041101';
> select * from test where test_date between 20041001 and 20041101;

In the latter case the constants are integers, not dates.  IMHO the best
policy would be for Postgres to reject it as an invalid operation, since
there are no date-vs-integer comparison operators.  What you are
actually getting though is an implicit coercion of both sides to text
followed by a textual comparison, as you can see if you look at EXPLAIN
output:

regression=# create table test(test_date date);
CREATE TABLE
regression=# explain select * from test where test_date between '20041001' and 
'20041101';
 QUERY PLAN
-
 Seq Scan on test  (cost=0.00..25.00 rows=5 width=4)
   Filter: ((test_date >= '2004-10-01'::date) AND (test_date <= '2004-11-01'::date))
(2 rows)

regression=# explain select * from test where test_date between 20041001 and 20041101;
   QUERY PLAN
-
 Seq Scan on test  (cost=0.00..30.00 rows=5 width=4)
   Filter: (((test_date)::text >= '20041001'::text) AND ((test_date)::text <= 
'20041101'::text))
(2 rows)

I've been harping for awhile on the notion that having all these implicit
cross-type-category coercions to text is Evil And Dangerous, and this is
another example in support of that theory.  But I fully expect a lot of
people to scream loudly if we disable these implicit coercions.  You can
bet there is someone out there who thinks he should be able to do
select 'Today is ' || current_date;
without having to write an explicit cast to text.

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]