Re: [SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > That's because a quoted literal isn't necessarily a timestamp. Without > context it could be anything, and in the context of comparing to a date > the planner probably tries to make it a date. I think the real point here is this: regression=# select '2

Re: [SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Richard Huxton
Stefano Buliani wrote: > Richard, > > understand I shouldn't be comparing a date to a timestamp. Fact is I > need the full timestamp to process other info in the rest of the function. > > My question is: why is the planner casting the timestamp to date when I > run the query from psql and the oth

Re: [SQL] store pdf files

2008-12-09 Thread Andreas Joseph Krogh
On Tuesday 09 December 2008 18:57:15 Frank Bax wrote: > ivan marchesini wrote: > > Hi to all... > > I need to create a db that contain link to some pdf files.. > > At the moment these are simple links (to the files that are stored into > > the file system) storing paths into a column of a dbf table

Re: [SQL] store pdf files

2008-12-09 Thread Thomas Kellerer
ivan marchesini wrote on 09.12.2008 11:11: Hi to all... I need to create a db that contain link to some pdf files.. At the moment these are simple links (to the files that are stored into the file system) storing paths into a column of a dbf table... I need to manage this data considering that t

Re: [SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Richard Huxton
Stefano Buliani wrote: > If I run this query from the psql client it works just fine. From the > function it doesn't return anything. > What I discovered is that for it to work from the function I need to > explicitly cast the tradedate variable to DATE (ie '2008-12-08 > 02:00:00'::DATE - Note t

Re: [SQL] store pdf files

2008-12-09 Thread Frank Bax
ivan marchesini wrote: Hi to all... I need to create a db that contain link to some pdf files.. At the moment these are simple links (to the files that are stored into the file system) storing paths into a column of a dbf table... I need to manage this data considering that the db I'm going to c

[SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Stefano Buliani
Hello all, I'm experiencing a strange problem with postgresql 8.3.4. I have the following table tx_queue txid serial securityid integer portfolioid integer datequeued timestamp default now() tradedate date numshares numeric(25,7) transactiontype char(1) tradeprice numeric(25,7) every time a new

[SQL] store pdf files

2008-12-09 Thread ivan marchesini
Hi to all... I need to create a db that contain link to some pdf files.. At the moment these are simple links (to the files that are stored into the file system) storing paths into a column of a dbf table... I need to manage this data considering that the db I'm going to create will be moved in so

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
Tom Lane wrote: > Richard Huxton <[EMAIL PROTECTED]> writes: >> Tom Lane wrote: >>> Richard Huxton <[EMAIL PROTECTED]> writes: Anyone got anything more elegant? >>> Seems to me that no document should have an empty dup_set. If it's not >>> a match to any existing document, then immediately as

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Richard Huxton <[EMAIL PROTECTED]> writes: >>> Anyone got anything more elegant? >> >> Seems to me that no document should have an empty dup_set. If it's not >> a match to any existing document, then immediately assign a new dup_set

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
Tom Lane wrote: > Richard Huxton <[EMAIL PROTECTED]> writes: >> Anyone got anything more elegant? > > Seems to me that no document should have an empty dup_set. If it's not > a match to any existing document, then immediately assign a new dup_set > number to it. That was my initial thought too,

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Anyone got anything more elegant? Seems to me that no document should have an empty dup_set. If it's not a match to any existing document, then immediately assign a new dup_set number to it. regards, tom lane -- Sent via pgsq

Re: [SQL] DIVISION with Group By

2008-12-09 Thread Richard Huxton
hdhgdh mjhff wrote: > Hai all, > > I am new to SQL coding. > I need some help in writing SQL > In my task i have to calculate division of two sub queries. > each sub query has its own group by clause. Can you provide a simpler example? It's not obvious to me what you're trying to do. -- Richa

[SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
The scenario is - a list of documents, some of which may be (near) duplicates of others, one document being in many duplicate-sets and a duplicate-set containing many documents. We want to see a list with only one document (any one) from each duplicate set. There's an example script attached. So: