dbTalk Databases Forums  

Re: trouble with my c/sql-code on SE 7.23

comp.databases.informix comp.databases.informix


Discuss Re: trouble with my c/sql-code on SE 7.23 in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Art Kagel
 
Posts: n/a

Default Re: trouble with my c/sql-code on SE 7.23 - 03-05-2010 , 09:44 AM






You cannot depend on the value in sqlca.sqlerrd[2] until the last row was
returned from the server. I'm guessing that 92 is the number of rows that
fits into a default sized (4K) communications buffer and so when the engine
returns that first buffer to the ESQL/C library it already contains the
last row and so the count has been updated. If there are more rows than fit
into a single buffer, then the count in sqlca.sqlerrd[2] will not be updated
until the buffer containing the last row is returned from the engine. You
could expand the comms buffer size with the FET_BUF_SIZE environment
variable or by setting the fetbusize global variable immediately after
connecting to the database but before any DML is issued. You can set the
buffer up to 32765 bytes which would hold over 1500 rows in a single
physical fetch, but someday you might exceed that and then your reliance on
this value will fail again.

If you need the count before counting them yourself in the code you will
need to execute an identically (or at least equivalently) filtered query
that returns just the COUNT(*). You don't need the count to regulate the
FETCH loop, you can do that using the "(sqlca.sqlcode == SQLNOTFOUND)" test
or its inverse to manage the loop. For pre-sizing an array to fetch data
into, you'll have to either go the COUNT(*) route, or dynamically resize the
array as you go. I have many apps like that where I allocate an array big
enough for most runs and if there is more data I reallocate the array with
an additional block of N more rows and again if I've exhausted the extra
space, etc.

Art

Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
IIUG Board of Directors (art (AT) iiug (DOT) org)

See you at the 2010 IIUG Informix Conference
April 25-28, 2010
Overland Park (Kansas City), KS
www.iiug.org/conf

Disclaimer: Please keep in mind that my own opinions are my own opinions and
do not reflect on my employer, Advanced DataTools, the IIUG, nor any other
organization with which I am associated either explicitly, implicitly, or by
inference. Neither do those opinions reflect those of other individuals
affiliated with any entity with which I am affiliated nor those of the
entities themselves.



On Fri, Mar 5, 2010 at 10:22 AM, Peter Michel <
proORGA-Leimen.without-this (AT) web (DOT) de> wrote:

Quote:
Hi,
the following code works great,
until the count of records is more than 92 8-((

$declare zeigerc cursor for select
chrst_charge, chrst_kurztext, chrst_status, chrst_ende,
chrst_benutzt, chrst_nr_intern
from chargestamm
where chrst_kategorie = $chrst_kategorie
and chrst_artikelnr = $chrst_artikelnr
and chrst_start <= TODAY and chrst_ende >= TODAY
and chrst_status in (" ", "X")
order by 5 desc, 4;
IFDBERROR("declare-c");

$open zeigerc;
IFDBERROR("open-c");

$fetch zeigerc into
$chrst_charge, $chrst_kurztext, $chrst_status, $chrst_ende,
$chrst_benutzt, $chrst_nr_intern;
IFSQLCODE IFNOTNOTFOUND("fetch-c");

anz = (short)sqlca.sqlerrd[2];

If the founded subset of records is <=92 the variable 'anz' has the
correct value (0 to 92) BUT is it >92 records the slqca.sqlerrd[2] is
zero and no error is shown (sqlcode is zero too) and - as expected -
there are all the wanted records present.

Has anybody an idea?

Cheers
Peter

Für direkte email rot13 cebBETN-Yrvzra (AT) jro (DOT) qr
oder entferne ".without-this" aus der Email-To. Danke!
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.