X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5F166D1B4C5 for ; Tue, 30 Dec 2003 16:06:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19334-02 for ; Tue, 30 Dec 2003 12:06:02 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 5E89FD1B4A9 for ; Tue, 30 Dec 2003 12:06:01 -0400 (AST) Received: (qmail 10773 invoked by uid 500); 30 Dec 2003 16:06:07 -0000 Date: Tue, 30 Dec 2003 10:06:07 -0600 From: Bruno Wolff III To: John Sidney-Woollett Cc: Ericson Smith , "pgsql-general@postgresql . org" Subject: Re: Is my MySQL Gaining ? Message-ID: <20031230160607.GA29408@wolff.to> Mail-Followup-To: John Sidney-Woollett , Ericson Smith , "pgsql-general@postgresql . org" References: <20031229151814.46230.qmail@web20801.mail.yahoo.com> <1072714860.1687.121.camel@localhost.localdomain> <1072728193.3ff0888143061@webmail.vcsn.com> <1072729267.1687.136.camel@localhost.localdomain> <3FF093B4.2040904@did-it.com> <20031229210938.GB19279@wolff.to> <3FF09A2E.8010904@did-it.com> <3FF09C96.4050901@did-it.com> <20031229213912.GD19279@wolff.to> <4329.192.168.0.64.1072741282.squirrel@mercury.wardbrook.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4329.192.168.0.64.1072741282.squirrel@mercury.wardbrook.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/1531 X-Sequence-Number: 54924 On Mon, Dec 29, 2003 at 23:41:22 -0000, John Sidney-Woollett wrote: > Actually, sometimes these questions will be postgres specific, and this is > where the docs are too light. > > An example is an update statement using values from a correlated subquery. > Here's example code in pgsql: > > update PHOTO.WPImage > set WPImageStateID = 3, > Width = WPImageHeader.Width, > Height = WPImageHeader.Height, > ContentType = WPImageHeader.ContentType, > ContentLength = WPImageHeader.ContentLength > where WPImage.WDResourceID = WPImageHeader.WDResourceID > and WPImage.WDResourceID = pResourceID > and WPImage.WPSizeTypeID = 0; > > In Oracle this might be written: > > update PHOTO.WPImage i > set WPImageStateID = 3, > (Width, Height, ContentType, ContentLength) = ( > select Width, Height, ContentType, ContentLength > from PHOTO.WPImageHeader ih > where ih.WDResourceID = i.WDResourceID) > where WPImage.WDResourceID = pResourceID > and WPImage.WPSizeTypeID = 0; > > You'll notice that the syntax is entirely different, and very relevant for > inclusion in the docs for each database's update statement. The Postgres example uses a join instead of subselects. You could have used subselects in postgres, but because there is currently not a way to set more than one column at a time from one subselect, you would have to repeat the subselect 4 times. I am not convinced that this needs to be documented in the section on the update statement. This is something that would belong in an oracle to postgres conversion guide. > I've mentioned it before but here it is again, contrast this explanation > of the UPDATE command in postgres with Oracle's explanation. Which one > would explain how to make use of a correlated subquery without resorting > to more googling or the list? > > postgres: http://www.postgres.org/docs/current/interactive/sql-update.html > > Oracle: http://miami.int.gu.edu.au/dbs/7016/a85397/state27a.htm#2067717 > > My point is not so much that the docs are difficult for newbies (and they > probably are), but that they just lack sufficient meat which really ought > to be included. I still don't see that there needs to be a lot more added to the postgres update command documentation. The main thing missing is links to the syntax definitions for things like from list, condition and expression. Currently you just have to know that the syntax for from items and conditions is described with the select documentation and that expression syntax is covered in the value expressions chapters under sql syntax.