Re: TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-30 Thread Bruce Momjian
Does Oracle have a syntax for this? --- Robert Treat wrote: > On Wednesday 23 July 2003 19:06, Bruce Momjian wrote: > > Robert Treat wrote: > > > On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > > > > FOR myrec IN E

[SQL]

2003-07-30 Thread Vishal Charan (IT Fiji)
Unsubscribe ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] Unsubscribe

2003-07-30 Thread 2000info
Unsubscribe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEma

Re: [SQL] One to many query question

2003-07-30 Thread Dave Dribin
On Wed, Jul 30, 2003 at 05:26:23PM -0400, Dmitry Tkach wrote: > >How do I write a query to find all CDs that are NOT Rock? > > > What about > select * from cd where not exists (select 1 from cd_genres where cd_id > = cd.id and genre='Rock')? Thanks everyone! This did indeed work, and it does se

Re: [SQL] One to many query question

2003-07-30 Thread Eric Clark
> This doesn't allow multiple genre's per CD, though, does it? A CD > can only have 1 genre_id. I would like the ability to have multiple > genres, in which case a third table is necessary: > > CREATE TABLE cd_genres ( > cd_id integer, > genre_id integer > ); > > cd_id references cd.id

Re: [SQL] One to many query question

2003-07-30 Thread Chad Thompson
> On Wed, Jul 30, 2003 at 01:11:35PM -0700, Eric Clark wrote: > > On Wed, 2003-07-30 at 12:35, Dave Dribin wrote: > > > CREATE TABLE cd ( > > > id integer unique, > > > artist varchar(25), > > > title varchar(25) > > > ); > > > > > > CREATE TABLE cd_genres ( > > > cd_id integer, > > > genre varchar

Re: [SQL] One to many query question

2003-07-30 Thread Dmitry Tkach
Dave Dribin wrote: Hi, I'm having trouble with what I think should be an easy query. For simplicity, I will use a CD database as an example. Each CD may have multiple genres. Here's some sample data: Artist Title Genres --

Re: [SQL] One to many query question

2003-07-30 Thread Richard Huxton
On Wednesday 30 July 2003 20:35, Dave Dribin wrote: > Hi, I'm having trouble with what I think should be an easy query. For > simplicity, I will use a CD database as an example. Each CD may have > multiple genres. Here's some sample data: > > Artist Title

Re: [SQL] Nonexistent NEW relation in some places of rules

2003-07-30 Thread Denis Zaitsev
On Tue, Jul 29, 2003 at 06:32:44PM -0400, Tom Lane wrote: > The problem is that the rule gets expanded into something rather like > > insert into a select ... from new, produce(new.b); > > and we can't support that. If we ever add support for SQL99's > LATERAL(), it might help improve matt

Re: [SQL] One to many query question

2003-07-30 Thread Dave Dribin
On Wed, Jul 30, 2003 at 01:11:35PM -0700, Eric Clark wrote: > On Wed, 2003-07-30 at 12:35, Dave Dribin wrote: > > CREATE TABLE cd ( > > id integer unique, > > artist varchar(25), > > title varchar(25) > > ); > > > > CREATE TABLE cd_genres ( > > cd_id integer, > > genre varchar

Re: [SQL] One to many query question

2003-07-30 Thread Eric Clark
On Wed, 2003-07-30 at 12:35, Dave Dribin wrote: > CREATE TABLE cd ( > id integer unique, > artist varchar(25), > title varchar(25) > ); > > CREATE TABLE cd_genres ( > cd_id integer, > genre varchar(25) > ); I think you've got this backwards. There is no advantage i

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Stephan Szabo
On Wed, 30 Jul 2003, Jamie Lawrence wrote: > I have a view: > > create or replace view addenda as > select > documents.id, > documents.oid, > documents.projects_id, > documents.doc_num, > documents.description, > documents.date, > documents.

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Josh Berkus
Richard, > I think this is the "adding a table into the FROM" feature of PG. You're > referring to documents.xxx in the select and d.id in the FROM. PG tries to > help out by adding the table into the FROM for you - hence cartesian join. Aha! You're right. > I think you can turn this "feature

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Richard Huxton
On Wednesday 30 July 2003 21:07, Jamie Lawrence wrote: > I fully admit that I've been staring at this too long, and simply don't > understand what is wrong. Apologies aside, any kind sql hackers who care > to look this over will earn my undying gratitude, and a beer in the bar > of your choice, sho

[SQL] One to many query question

2003-07-30 Thread Dave Dribin
Hi, I'm having trouble with what I think should be an easy query. For simplicity, I will use a CD database as an example. Each CD may have multiple genres. Here's some sample data: Artist Title Genres -- ---

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Josh Berkus
Jamie, > General issue: I'm getting cartesean products instead of left joins, and > I feel like a moron. No, this is extremely bizarre. I can't think of an explanation for the results you're getting, except that the view definition isn't what you think it is. Can you do a \d addenda and post

Re: [SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread Rajesh Kumar Mallah
if the constraint are named $1 $2 etc you will need to quote them eg ALTER TABLE xyz DROP CONSTRAINT "$1" ; in some version you may require ALTER TABLE xyz DROP CONSTRAINT "$1" RESTRICT; What is ur version btw? try to post the table structure also. regds mallah. Elielson Fontanezi wrote: H

[SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Jamie Lawrence
I fully admit that I've been staring at this too long, and simply don't understand what is wrong. Apologies aside, any kind sql hackers who care to look this over will earn my undying gratitude, and a beer in the bar of your choice, should we ever meet. General issue: I'm getting cartesean produ

Re: [SQL] Problem using Subselect results

2003-07-30 Thread Josh Berkus
Oliver, > SELECT DISTINCT ON (two.two_id) two.two_value FROM one,two WHERE > (one.two_id=two.two_id > AND one.updatenr > two.updatenr) ORDER BY two.updatenr ASC; FWIW, SELECT DISTINCT ON () is slower than SELECT ORDER BY ... LIMIT 1 on all stable versions of Postgres. Not that the LIMIT

Re: [SQL] function returning setof performance question

2003-07-30 Thread Josh Berkus
Mark, I'm crossing this over to the performance list; it's really appropriate on both lists. So I'm quoting you in full as well. > I have a question regarding the performance of a function returning a > set of a view as opposed to just selecting the view with the same > where clause. Please

Re: [SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread George Weaver
It works in 7.3.2.   George - Original Message - From: Elielson Fontanezi To: pgsql-general ; pgsql-sql Sent: Wednesday, July 30, 2003 10:52 AM Subject: [SQL] ALTER TABLE ... DROP CONSTRAINT Hi all!       Who can tell me what postgres version supports

Re: [SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread Rod Taylor
I think you can do some constraints in 7.2, but 7.3 will allow dropping them all in that fashion. On Wed, 2003-07-30 at 11:52, Elielson Fontanezi wrote: > Hi all! > > Who can tell me what postgres version supports ALTER TABLE... DROP > CONSTRAINT without > the need of droping the table to re

Re: [SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread Chad Thompson
  Hi all!       Who can tell me what postgres version supports ALTER TABLE... DROP CONSTRAINT without the need of droping the table to remove a simple coinstraint. (link)    >\\\!/< 55 11 5080 9283 

[SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread Elielson Fontanezi
Hi all!       Who can tell me what postgres version supports ALTER TABLE... DROP CONSTRAINT without the need of droping the table to remove a simple coinstraint. (link)    >\\\!/< 55 11 5080 9283   !_"""_! Elielson

Re: [SQL] now 7.2.3 - 7.3.3

2003-07-30 Thread Tom Lane
"A. Van Hook" <[EMAIL PROTECTED]> writes: > this worked in 7.2.3 > "select sum(cr) from ar where date(tdate) = now() -1 " > but not in 7.3.3 > What's the proper syntax for 7.3.3??? Perhaps you want current_date - 1. regards, tom lane ---(end of br

Re: [SQL] Very strange 'now' behaviour in nested triggers.

2003-07-30 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Strangely, CURRENT_TIMESTAMP converts to 'now', not now(). Is that a > problem? No, it is not, because the text-to-timestamptz conversion is marked volatile and won't be const-folded. I've always thought it was a very ugly implementation though, mainly

Re: [SQL] How can I to solute this problem?

2003-07-30 Thread Achilleus Mantzios
You may take a look at jboss connection pool mechanism. (postgresql.xml). Also a good way of ensuring that your app will not leave open stale postgresql connections is to initially configure your pool to only have a small number of connections (e.g. 2,3). If your J2EE components (e.g. jsps) are

Re: [SQL] How can I to solute this problem?

2003-07-30 Thread Paul Thomas
On 30/07/2003 10:43 LEON wrote: Hi,Thank your help yesterday. Now I met a new question. When I continued to clicking UI(jsp) some time, I will get a error in page.It is "Http 404" and Exception is "NullPoinerExcaption". I checked the log of tomcat. It recorded a message"connected database failed.

Re: [SQL] now 7.2.3 - 7.3.3

2003-07-30 Thread Peter Eisentraut
A. Van Hook writes: > this worked in 7.2.3 > "select sum(cr) from ar where date(tdate) = now() -1 " > but not in 7.3.3 > What's the proper syntax for 7.3.3??? now() - interval '1 day/minute/year/second/???' -- Peter Eisentraut [EMAIL PROTECTED] ---(end of broadcast)-

[SQL] now 7.2.3 - 7.3.3

2003-07-30 Thread A. Van Hook
this worked in 7.2.3 "select sum(cr) from ar where date(tdate) = now() -1 " but not in 7.3.3 What's the proper syntax for 7.3.3??? thanks ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] How can I to solute this problem?

2003-07-30 Thread LEON
Hi,Thank your help yesterday. Now I met a new question. When I continued to clicking UI(jsp) some time, I will get a error in page.It is "Http 404" and Exception is "NullPoinerExcaption". I checked the log of tomcat. It recorded a message"connected database failed. The user perporty is missing.

Re: [SQL] time precision.

2003-07-30 Thread Stephan Szabo
On Wed, 30 Jul 2003, Anagha Joshi wrote: > Hi All, > I'm using PG-7.2.4 on Solaries. > When I do: > > template1=# select time(6576); > ERROR: TIME(6576) precision must be between 0 and 13 > > Where am I wrong? IIRC time(n) refers to the type time with a precision of n and n is limited as stated

Re: [SQL] time precision.

2003-07-30 Thread Christoph Haller
> I'm using PG-7.2.4 on Solaries. > When I do: > > template1# select time(6576); > ERROR: TIME(6576) precision must be between 0 and 13 > > Where am I wrong? What's the purpose of this function? And where did you find it in the docs? I didn't see it before. Regards, Christoph

Re: [SQL] Problem using Subselect results

2003-07-30 Thread oheinz
I did try the following: SELECT DISTINCT ON (two.two_id) two.two_value FROM one,two WHERE (one.two_id=two.two_id AND one.updatenr > two.updatenr) ORDER BY two.updatenr ASC; I thought this would a) order the result list by updatenr b) return the first record only for records that are equal on th

[SQL] time precision.

2003-07-30 Thread Anagha Joshi
Hi All, I’m using PG-7.2.4 on Solaries. When I do:   template1=# select time(6576); ERROR:  TIME(6576) precision must be between 0 and 13   Where am I wrong? Pls. help   Thanks, Anagha