Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id AF699632DC4 for ; Mon, 24 May 2010 15:33:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 56976-04 for ; Mon, 24 May 2010 18:33:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.154]) by mail.postgresql.org (Postfix) with ESMTP id 1CA5363249C for ; Mon, 24 May 2010 15:33:43 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id d23so1967091fga.1 for ; Mon, 24 May 2010 11:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=wLySSzuQpKdvNuNLrmvtGQSR/4GJImAv1ffvso6ZFM0=; b=QHKvV0EgZ2Tz6k2uv5OfMzprUEr+69HtHhta/aorlw1b1SGaIBCQD6pfVnhsKx/2Ep QHeHmEW1577bY9LYNgnlpdd/YZeqbxBoemGkzyZpbLV/Oy3RSg/g4hzSTJM9iIw+qdGj yYZ/XGUrf5/1cbKL9bzmWOCQ42Bb7aid2sbeo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=KBzSBMjIZgpM4STyhVji/ggdz5/+xNsbbWwJ1rtN+hTBBtjiiOrStAUzE16HYSmMzw wHeq9WXgdOdfV5F7q/HB70jUtGvJkSpUcb+ZSdLotBBYz0rGnx+wXelywhh2VjTLRvLB VWUoVN9OEN07GN5JPcMC2KCLexTF9Y1et5Y/4= Received: by 10.102.211.40 with SMTP id j40mr4488665mug.69.1274726022050; Mon, 24 May 2010 11:33:42 -0700 (PDT) Received: from [192.168.1.3] (bzq-84-109-195-101.red.bezeqint.net [84.109.195.101]) by mx.google.com with ESMTPS id n10sm16537364mue.12.2010.05.24.11.33.39 (version=SSLv3 cipher=RC4-MD5); Mon, 24 May 2010 11:33:41 -0700 (PDT) Message-ID: <4BFAC67F.8050504@gmail.com> Date: Mon, 24 May 2010 21:33:35 +0300 From: David Harel User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: postgres sql Subject: User function that returns a set of rows. Content-Type: multipart/alternative; boundary="------------000303050104040704080704" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.01 tagged_above=-5 required=5 tests=BAYES_40=-0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_FILL_THIS_FORM_SHORT=0.01 X-Spam-Level: X-Archive-Number: 201005/110 X-Sequence-Number: 34158 This is a multi-part message in MIME format. --------------000303050104040704080704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I'm struggling to write what seed at the time a simple function like: "CREATE FUNCTION foo() RETURNS IDONO as $$ select * from tbl; return (whatever that will give the *); $$ up till now I got this far: CREATE OR REPLACE FUNCTION select_business_types () RETURNS SETOF RECORD AS $body$ DECLARE rec RECORD; -- fields business_type_id business_type_name BEGIN FOR rec IN SELECT * FROM sv_bo_business_types LOOP RETURN NEXT rec; END LOOP; RETURN; END; $body$ LANGUAGE 'plpgsql'; When I tried it from the shell I got a nasty error message about that I am not in an environment to receive a set ??? (can't see it now. Office restrictions). Any idea? -- Regards. David Harel, ================================== Home office +972 77 7657645 Cellular: +972 54 4534502 Snail Mail: Amuka D.N Merom Hagalil 13802 Israel Email: hareldvd@ergolight-sw.com --------------000303050104040704080704 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi,

I'm struggling to write what seed at the time a simple function
like:
"CREATE FUNCTION foo() RETURNS IDONO as
$$
  select * from tbl;
  return (whatever that will give the *);
$$

up till now I got this far:

CREATE OR REPLACE FUNCTION select_business_types ()

RETURNS SETOF RECORD

AS

$body$

DECLARE

  rec RECORD;

-- fields business_type_id business_type_name

BEGIN

      FOR

            rec IN SELECT * FROM sv_bo_business_types

      LOOP

            RETURN NEXT rec;

      END LOOP;

      RETURN;

END;

$body$

LANGUAGE 'plpgsql';

When I tried it from the shell I got a nasty error message about that I am not in an environment to receive a set ??? (can't see it now. Office restrictions).

Any idea?
-- 
Regards.

David Harel,

==================================

Home office +972 77 7657645
Cellular:   +972 54 4534502
Snail Mail: Amuka
            D.N Merom Hagalil
            13802
            Israel
Email:      hareldvd@ergolight-sw.com

--------------000303050104040704080704--