From mark@manngo.net Sun Nov 5 06:51:08 2006 Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id B97E49F9EF0 for ; Sun, 5 Nov 2006 02:51:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 12750-01 for ; Sun, 5 Nov 2006 06:51:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8DE629FA001 for ; Sun, 5 Nov 2006 02:51:04 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from localhost.localdomain (unknown [58.105.225.59]) by svr4.postgresql.org (Postfix) with ESMTP id 0515F5AF03C for ; Sun, 5 Nov 2006 06:21:07 +0000 (GMT) Received: from [127.0.0.1] ([192.168.1.5]) by localhost.localdomain (8.13.1/8.12.11) with ESMTP id kA56L0e2013220 for ; Sun, 5 Nov 2006 17:21:03 +1100 Message-ID: <454D82CC.6090503@manngo.net> Date: Sun, 05 Nov 2006 17:21:00 +1100 From: Mark Simon User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Create Function (SQL) Content-Type: multipart/alternative; boundary="------------050604060907090105080608" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.271 tagged_above=0 required=5 tests=BAYES_50, FORGED_RCVD_HELO, HTML_50_60, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200611/52 X-Sequence-Number: 26704 This is a multi-part message in MIME format. --------------050604060907090105080608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I am trying to create a simple function using SQL rather than PGSQL. At this point, it's just for the exercise. Is it possible to create a function similar to the following: create function thing(text) as select * from whatever where id=$1; Do I need to specify all of the columns from the table (whatever) as out parameters, or as a return type, or can I have a generic table returned from this? Thanks, Mark -- Mark Simon Manngo Net Pty Ltd Phone/Fax: 1300 726 000 mobile: 0411 246 672 email: mark@manngo.net web: http://www.manngo.net Resume: http://mark.manngo.net --------------050604060907090105080608 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I am trying to create a simple function using SQL rather than PGSQL. At this point, it's just for the exercise.

Is it possible to create a function similar to the following:

    create function thing(text) as select * from whatever where id=$1;

Do I need to specify all of the columns from the table (whatever) as out parameters, or as a return type, or can I have a generic table returned from this?

Thanks,

Mark
--

Mark Simon

Manngo Net Pty Ltd

Phone/Fax: 1300 726 000
mobile: 0411 246 672

email: mark@manngo.net
web: http://www.manngo.net

Resume: http://mark.manngo.net

--------------050604060907090105080608-- From immaad@gmail.com Sun Nov 5 11:59:18 2006 Received: from localhost (uranus.hub.org [200.46.204.60]) by postgresql.org (Postfix) with ESMTP id B19CC9FA20E for ; Sun, 5 Nov 2006 07:59:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.60]) (amavisd-new, port 10024) with ESMTP id 04471-10 for ; Sun, 5 Nov 2006 07:59:17 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.189]) by postgresql.org (Postfix) with ESMTP id 639729FA19A for ; Sun, 5 Nov 2006 07:59:17 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x37so2284064nfc for ; Sun, 05 Nov 2006 03:59:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=E48UYKTOQzrMZASj3o81PL/i0Nbqa7TAK8dGC52iJalYqn1tcweTQK1sCctNcCz8o/Gy/209WccMLkBpGOCtDyXFCLXrIdK8Nlnfdoy/vW1Y4mayMQ1IlY1XgmkhGyLnfG9fMU0K2XQ2KQlIZOy6mL0VQv9RxZDEXtqje1A3bZY= Received: by 10.82.114.3 with SMTP id m3mr1103871buc.1162727954542; Sun, 05 Nov 2006 03:59:14 -0800 (PST) Received: by 10.82.161.3 with HTTP; Sun, 5 Nov 2006 03:59:14 -0800 (PST) Message-ID: <1f30b80c0611050359l5208a40fo5276f7df3cf65371@mail.gmail.com> Date: Sun, 5 Nov 2006 16:59:14 +0500 From: imad To: "Mark Simon" Subject: Re: Create Function (SQL) Cc: pgsql-sql@postgresql.org In-Reply-To: <454D82CC.6090503@manngo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <454D82CC.6090503@manngo.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/54 X-Sequence-Number: 26706 You can return a record: create function thing(text) returns record as 'select * from whatever where id=$1' language sql; Hope this helps. --Imad www.EnterpriseDB.com On 11/5/06, Mark Simon wrote: > > I am trying to create a simple function using SQL rather than PGSQL. At > this point, it's just for the exercise. > > Is it possible to create a function similar to the following: > > create function thing(text) as select * from whatever where id=$1; > > Do I need to specify all of the columns from the table (whatever) as out > parameters, or as a return type, or can I have a generic table returned from > this? > > Thanks, > > Mark > > -- > > > Mark Simon > > Manngo Net Pty Ltd > > Phone/Fax: 1300 726 000 > mobile: 0411 246 672 > > email: mark@manngo.net > web: http://www.manngo.net > > Resume: http://mark.manngo.net