× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Chuck,

I have tried using SQLGetDiagField as well and have not had any success
using it either. It is returning a SQLRETURN value of 0 and a vRowCount
value of 0. After the call the pointer pRowCount is also changed to
*NULL. The result set contains at least a billion rows and I have tested
with smaller result sets resulting in the same issue. Please see the code
below.

Any thoughts would be greatly appreciated.


*-------------------------------------------------------------------------
* Procedure name: SQLCLI_getResultRowCount
* Purpose: Get the Result Set Row Count
* Returns: Returned Result Set Row Count
* Parameter: piStmtHandle => Statement Handle

*-------------------------------------------------------------------------
p SQLCLI_getResultRowCount...
p b export
d SQLCLI_getResultRowCount...
d pi 10i 0
d piStmtHandle 10i 0
d* piConnHandle 10i 0

* Local definitions
d pRowCount s * inz
d vBLen s 5i 0 inz
d vRecNum s like(SQLSMALLINT) inz(0)
d vRowCount s 10i 0 inz
d vSLen s 5i 0 inz
d vSQLRC s 10i 0 inz
d vStmtHandle s like(SQLINTEGER) inz

/free

vStmtHandle = piStmtHandle;

pRowCount = %addr(vRowCount);
vBLen = %len(vRowCount);
vSLen = 0;

vSQLRC = SQL_GetDiagField(SQL_HANDLE_STMT :vStmtHandle :vRecNum
:SQL_DIAG_ROW_COUNT :pRowCount :vBLen :vSLen);
if vSQLRC <> 0;
@ErrorDs = SQLError(vStmtHandle);
endif;

return vRowCount;


//----------------------------------------------------------------------
// Subprocedure error handling routine

//----------------------------------------------------------------------
begsr *pssr;
dump(a) 'SubProc(SQLCLI_getResultRowCount)';
vRowCount = -1;
return vRowCount;
endsr;

/end-free
p SQLCLI_getResultRowCount...
p e


On Fri, May 29, 2015 at 2:57 PM, CRPence <crpbottle@xxxxxxxxx> wrote:

On 29-May-2015 14:29 -0500, Mike Garrison wrote:

Code is as follows:
<<SNIP>>
vSQLRC = SQL_GetDescField(vDescHandle :vRecNum :SQL_DESC_COUNT
:pRowCount :vBLen :vSLen);
<<SNIP>>


AIUI the above request obtains the number of /records/ returned in the
descriptor, not the estimated number of rows in a result set.


Perhaps look at the following API instead, for which the
SQL_DIAG_ROW_COUNT might be the equivalent of SQLERRD(2):

<
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/cli/rzadpfndfld.htm

SQLGetDiagField - Return diagnostic information (extensible)


And for reference, per mention of SQLERRD:

<
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzfielddescsqlca.htm

IBM i 7.2->Database->Reference->SQL reference->SQLCA (SQL communication
area)->
_Field descriptions_
SQLERRD(2) ...
...
For an OPEN statement, if the cursor is insensitive to
changes, SQLERRD(2) contains the actual number of rows in the result set.
If the cursor is sensitive to changes, SQLERRD(2) contains an estimated
number of rows in the result set.
..."

--
Regards, Chuck


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.