X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 4EE229FB21B for ; Sat, 15 Jul 2006 07:38:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 37710-09 for ; Sat, 15 Jul 2006 10:38:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from hu-out-0102.google.com (hu-out-0102.google.com [72.14.214.192]) by postgresql.org (Postfix) with ESMTP id 029249FB218 for ; Sat, 15 Jul 2006 07:38:16 -0300 (ADT) Received: by hu-out-0102.google.com with SMTP id 34so736629hui for ; Sat, 15 Jul 2006 03:38:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=EFjz9xQIS+Uzaw1EbL6TMIOBfJBpi1qfusAY0HoC7+QLfUjG1LAORINaoGskUpLRATDHQcUqHdlh1D4Nb+zOUvQ/IzdscVon1dmvoXW5TJZWtFRnBKR1S8dQ1dG4DmECkBQJTvNZUGfy7U1dmenuTlZ2Xn//9eAeHIJGA0xitvE= Received: by 10.78.156.6 with SMTP id d6mr149499hue; Sat, 15 Jul 2006 03:38:14 -0700 (PDT) Received: by 10.78.172.14 with HTTP; Sat, 15 Jul 2006 03:38:14 -0700 (PDT) Message-ID: <6534cdd0607150338j42f31e65vadfe975cb20cca2d@mail.gmail.com> Date: Sat, 15 Jul 2006 16:08:14 +0530 From: "sathiya moorthy" To: pgsql-sql@postgresql.org Subject: Doubt about User-defined function. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14183_8499375.1152959894561" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/214 X-Sequence-Number: 25788 ------=_Part_14183_8499375.1152959894561 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I have doubt about user-defined function returns value : * why function returns( accepts ) One attribute in the arguments of function/table, Otherwise it returns the whole record of the table. Function accept more than arguments . * Why it doesn`t return more than one arguments in the function (or) Attribute of that table. * Its like same as C-language function, Because in C function returns one value (or) structure/array of characters. * My question is, In psql user-defined function doesn`t returns more than one attribute. Is it possible (or) Not. Some examples : i) create function com2(text,integer) returns text as ' select city.city from city,weather where weather.city=$1 AND city.pop>$2' language sql; Res : Return type of the function is Text, As well as it is one of the argument of function. ( At the type of returning, why it doesn`t also accepts integer ). ii) create function usrs_tab(text,integer) returns city as 'select city.city,city.pop,city.state from city,weather where weather.city=$1 AND city.pop>$2' language sql; Res : Return one record from City table ( table contains city, pop, state only ). Thanking you. -- sathiyamoorthy ------=_Part_14183_8499375.1152959894561 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline        I have doubt about user-defined function returns value  :

             *  why function returns( accepts  ) One attribute in the arguments of function/table, Otherwise it returns the whole record of the table. Function accept more than arguments .
                      *   Why it doesn`t return more than one arguments in the function (or) Attribute of that table.

            *    Its like same as C-language function, Because in C function returns one value (or) structure/array of characters.

            *   My question is, In psql user-defined function doesn`t returns more than one attribute. Is it possible (or) Not.

     Some examples :
            i)      create function com2(text,integer) returns text as ' select city.city from city,weather
                    where weather.city=$1 AND city.pop>$2' language sql;

                    Res : Return type of the function is Text, As well as it is one of the argument of function.
                              ( At the type of returning, why it doesn`t  also accepts integer ).            
          ii)      create function usrs_tab(text,integer) returns city as 'select city.city,city.pop,city.state from                                        city,weather  where weather.city=$1 AND city.pop>$2' language sql;

                   Res : Return one  record from City table  ( table contains city, pop, state only ).


                                                   Thanking you.

--
sathiyamoorthy ------=_Part_14183_8499375.1152959894561--