Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4BDmbA76963 for ; Fri, 11 May 2001 09:48:37 -0400 (EDT) (envelope-from pgsql-general-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f48IumA09896 for ; Tue, 8 May 2001 14:56:48 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f48IYNZ32709 for pgsql-general@postgresql.org; Tue, 8 May 2001 14:34:23 -0400 (EDT) (envelope-from news) From: Roger Wernersson X-Newsgroups: comp.databases.postgresql.questions Subject: Re: SQL Server -> Postgres migration: Stored Procedure replacement? Date: Tue, 08 May 2001 20:31:13 +0200 Organization: Mindark Lines: 56 Message-ID: <3AF83B71.1C8DDDFA@mindark.com> References: <000601c0d202$203b2b10$2001a8c0@blockhead> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0smp i686) X-Accept-Language: en To: pgsql-general@postgresql.org X-Archive-Number: 200105/511 X-Sequence-Number: 9325 You just use a view. Period. CREATE VIEW foobarview AS SELECT a, c FROM foo; What else do you need? CREATE VIEW foobarview AS SELECT a*2 AS double, b*c AS multiple, max(a,c) AS maximum FROM foo; I believe views does it all. /Roger Eliel Mamousette wrote: > > "Tom Lane" writes: > > "Eliel Mamousette" writes: > [question re: returning rows deleted to conserve bits] > > > > You don't specify more than one return type --- you specify one return > > type that is a composite type. Composite types are currently tied to > > tables; creating a table also creates a type that represents one of its > > rows. Thus > > > > create table foo (a int, b int, c int); > > create function foobar (...) returns foo as ... > > Does rule also apply to views? > > For example, what is the best practice when one doesn't want to return > a whole row? Given the restriction as stated, if I only wanted to > return column a and c from the table above, would I create a view > fooview and then say that function foobarview returns fooview? > > If I write a paragraph about this process, to whom should I mail it for > inclusion in the documentation? I imagine it will be a FAQ for we who > are striving to escape from the legacy of Sybase and Microsoft's SQL > Server.... > > > Note that there are some annoying syntactic limitations on what you can > > actually *do* with a function returning tuples. We have plans to > > improve that situation in 7.2 or beyond, but for now, this facility > > isn't nearly as useful as one might think. > > Thanks Tom, but can you be a bit more specific about what one can't do > with returned tuples? It might save some folks (and me) some time. > > thanks again, this process has been extremely helpful, > eliel > > > regards, tom lane > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)