logo       

Re: ECPG - cursor fetch: msg#00033

Subject: Re: ECPG - cursor fetch
On Thu, Mar 10, 2005 at 01:51:07PM -0800, Mark Richardson wrote:
> I'm doing a port from Sybase's pre-compiler cpre, to ecpg and I have a couple 
> of questions (if anyone has the time).  This relates to cursors and fetching, 
> and what I would like to do is retrieve a bunch of records at one time - cpre 
> is able to fetch values into an array...
> EXEC SQL BEGIN DECLARE SECTION;
> int myInts[100];
> EXEC SQL END DECLARE SECTION;
> ...
> EXEC SQL DECLARE myCursor FOR SELECT
> myInt FROM myTable;
>  
> EXEC SQL FETCH myCursor INTO
> :myInts;
>  
> There is one mechanism that cpre uses to make sure that you don't exceed the 
> array size...
> EXEC SQL OPEN myCursor ROW_COUNT=100;
> then, every time you do a fetch, it retrives 100 rows.

This is usually done in the fetch statement and not in the open one.
Just use

EXEC SQL FETCH 100 myCursor INTO :myInts;

> Also, since I'm in the middle of a port, I'm trying to make the code work for 
> both with a different compile flag - but the pre-compilers don't care about 
> #defines.  Is there some other mecanism to tell ecpg to ignore or skip a 
> section?  I really don't want to have to make a "Pre-pre-compiler".  

EXEC SQL DEFINE/IFDEF/...

> I thought I would share this - the ecpg pre-compiler is much easier to work 
> with, and it handles things better than cpre when it comes to code 
> generation.  I think it would be much easier to port from ecpg to cpre than 
> what I am doing, because a lot of the non-standard options that are available 
> used/forced in cpre.  So thanks for all the work you guys have done.

Nice to hear that. :-)

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@xxxxxxxxxx
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe