X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id B92E69FA5E9 for ; Tue, 1 Aug 2006 04:40:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87643-05 for ; Tue, 1 Aug 2006 04:39:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from bottom.rox.net (bottom.rox.net [213.214.0.43]) by postgresql.org (Postfix) with ESMTP id 76A0D9FA374 for ; Tue, 1 Aug 2006 04:39:54 -0300 (ADT) Received: from localhost ([127.0.0.1]) by bottom.rox.net with esmtp (Exim 4.62) (envelope-from ) id 1G7or4-0001RX-GV; Tue, 01 Aug 2006 09:39:54 +0200 Received: from 6-052.vpn.rwth-aachen.de ([134.130.246.52] helo=mcknight.kawo2.rwth-aachen.de) by bottom.rox.net with esmtpa (Exim 4.62) (envelope-from ) id 1G7or3-0001Qn-8s; Tue, 01 Aug 2006 09:39:53 +0200 Received: by mcknight.kawo2.rwth-aachen.de (Postfix, from userid 1000) id 9D7494681B4; Tue, 1 Aug 2006 09:39:48 +0200 (CEST) Date: Tue, 1 Aug 2006 09:39:48 +0200 From: Joachim Wieland To: andy rost Cc: pgsql-interfaces@postgresql.org Subject: Re: Using FETCH ALL with descriptor areas Message-ID: <20060801073948.GA2236@mcknight.de> References: <44CA74FA.5010305@noaa.gov> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: <44CA74FA.5010305@noaa.gov> X-Operating-System: Linux 2.6.13.4 on an i686 User-Agent: Mutt/1.5.9i X-Scanned-By: rockenstein AG X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.027 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200608/2 X-Sequence-Number: 6216 --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jul 28, 2006 at 03:35:06PM -0500, andy rost wrote: > Is it possible, in ECPG, to use FETCH ALL with descriptor areas? If so, > can anyone provide a simple example. If not, does anyone have a get > around. We've found FETCH NEXT to be pretty expensive when selecting > even a modest number of tuples. I don't know if it is what you're looking for nor if it is faster at all but I attach an example with descriptors and auto-allocation. Joachim -- Joachim Wieland joe@mcknight.de GPG key available --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dynalloc2.pgc" #include exec sql include sqlca; #include exec sql include ../regression; int main(void) { exec sql begin declare section; int *ip1=0; char **cp2=0; int *ipointer1=0; int *ipointer2=0; int colnum; exec sql end declare section; int i; ECPGdebug(1, stderr); exec sql whenever sqlerror do sqlprint(); exec sql connect to REGRESSDB1; exec sql create table test (a int, b text); exec sql insert into test values (1, 'one'); exec sql insert into test values (2, 'two'); exec sql insert into test values (NULL, 'three'); exec sql insert into test values (4, 'four'); exec sql insert into test values (5, NULL); exec sql insert into test values (NULL, NULL); exec sql allocate descriptor mydesc; exec sql select * into descriptor mydesc from test; exec sql get descriptor mydesc :colnum=COUNT; exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR; exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR; printf("Result (%d columns):\n", colnum); for (i=0;i < sqlca.sqlerrd[2];++i) { if (ipointer1[i]) printf("NULL, "); else printf("%d, ",ip1[i]); if (ipointer2[i]) printf("NULL, "); else printf("'%s', ",cp2[i]); printf("\n"); } ECPGfree_auto_mem(); printf("\n"); exec sql deallocate descriptor mydesc; exec sql rollback; exec sql disconnect; return 0; } --azLHFNyN32YCQGCU--