Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 3D1849FA322 for ; Thu, 23 Aug 2007 11:55:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 99430-07 for ; Thu, 23 Aug 2007 11:55:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from bay0-omc2-s38.bay0.hotmail.com (bay0-omc2-s38.bay0.hotmail.com [65.54.246.174]) by postgresql.org (Postfix) with ESMTP id B08899F9A2D for ; Thu, 23 Aug 2007 11:55:13 -0300 (ADT) Received: from hotmail.com ([65.54.250.30]) by bay0-omc2-s38.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Thu, 23 Aug 2007 07:55:12 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 23 Aug 2007 07:55:11 -0700 Message-ID: Received: from 65.54.250.200 by by115fd.bay115.hotmail.msn.com with HTTP; Thu, 23 Aug 2007 14:55:10 GMT X-Originating-IP: [89.18.71.65] X-Originating-Email: [ramoloney@hotmail.com] X-Sender: ramoloney@hotmail.com From: "Roger Moloney" To: pgsql-interfaces@postgresql.org Subject: ecpg: HOW TO READ RECORD ?? Date: Thu, 23 Aug 2007 14:55:10 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 23 Aug 2007 14:55:11.0690 (UTC) FILETIME=[9B02FAA0:01C7E595] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/10 X-Sequence-Number: 6604 Hi, We use ecpg (embedded sql) and plpgsql (postgres functions). I'm having trouble trying to get embedded SQL to read the result of a plpgsql function which returns RECORD or SETOF RECORD. Does anyone have an example of this ? I don't see it in the ecpg source examples or in the ecpg manual. /* following is an example of plpgsql to illustrate the data being returned */ /* type defined for the record that the function will return to avoid using column list */ create type tp_GetPerson as ( person_name char(40), person_age smallint ); /* this function returns zero or more tp_GetPerson records */ create function p_GetPersonByDept (pperson_dept integer) returns SETOF tp_GetPerson as $$ declare v_record tp_GetPerson%ROWTYPE; begin for v_record in select person_name, person_age from person where person_dept = pperson_dept loop return next v_record; end loop; return; end $$ language 'plpgsql'; WHAT SHOULD THE ECPG PROGRAM LOOK LIKE THAT CAN READ THE DATA RETURNED ? thanks, RML _________________________________________________________________ Download the latest version of Windows Live Messenger NOW! http://get.live.com/en-za/messenger/overview