SelectKeyed C++

Karzmo

Karzmo

Active Member
Hi All,

My C++ skills are pretty limited but I have discovered an issue in a BSFN where on SelectKeyed the return value of idJDBReturn ALWAYS = JDEDB_PASSED (ie '1') even if there are no matching records. I don't really understand why (and clearly I don't understand what SelectKeyed does or returns) - can someone explain please :) I have checked the indexes on the table and even regenerated them. I have checked the log's as well and the select statement seems valid.

If there are no valid records I need the BSFN to finish otherwise it hangs further down (due to null pointers).

I have replicated the code here:

dsF55018Key.tm55ahtmqn = lpDS->n55TMQueryNumber;
jdeStrcpy(dsF55018Key.tm55ahstso, (const JCHAR *) (_J("A")));
idJDBReturn = JDB_SelectKeyed(dsOpenTables.hRequestF55018, ID_F55018_STATUS__QUERYNO__QUERYLINENO,
(void *)(&dsF55018Key), (short) 2);
if (idJDBReturn != JDEDB_PASSED)
{
jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("550053"), (LPVOID) NULL);
return ER_ERROR;
}

Thanks!
 
SelectKeyed just sends the SQL query to the database server. It responds with JDEDB_PASSED if all the parms are valid. You use JDB_Fetch to read the rows that are returned. If JDB_Fetch does not return JDEDB_PASSED, no more records. You would typically use JDB_Fetch in a while loop.

While (JDB_Fetch(hRequest, &dsRecord, 0) == JDEDB_PASSED)
{
/* Do something with dsRecord, a data structure containing the columns in your query */
}

Craig
 
Thanks Craig - I think they are just checking if there is at least one valid record before carrying on - if there are none stop processing.

So I guess underneath the SelectKeyed I should put a JDB_Fetch and use that to see if at least one record is returned? Is there a better way to check if there is at least one valid record? Can I use a fetch without a select keyed or so I need the select (like you do in JDE Tools - Select, Fetch Next type of thing?)

Hope that makes sense!
 
Thanks Craig - I think they are just checking if there is at least one valid record before carrying on - if there are none stop processing.

So I guess underneath the SelectKeyed I should put a JDB_Fetch and use that to see if at least one record is returned? Is there a better way to check if there is at least one valid record? Can I use a fetch without a select keyed or so I need the select (like you do in JDE Tools - Select, Fetch Next type of thing?)

Hope that makes sense!

JDB_FetchKeyed performs a select as well as fetch results. This API attempts to use the cache when fetching on business views. This should be used when you do not expect multiple records to be returned as a result of your query.

Syntax

JDEDB_RESULT JDB_FetchKeyed(HREQUEST hRequest, ID idIndex, void * lpKeyStruct, short nNumKeys, void * lpValue, int nLock);

NOTE: You should really grab the API guide

EDIT: link http://www.patwel.com/APIs/index.htm
 
Last edited:
I downloaded the API help file from patwel and it does show the individual API's, but there nothing shows up in the text display on the right side of the help window. Am I missing something here or is this the way the help file is? It is the older Windows CHM format.
 
I downloaded the API help file from patwel and it does show the individual API's, but there nothing shows up in the text display on the right side of the help window. Am I missing something here or is this the way the help file is? It is the older Windows CHM format.

Found out the problem. I needed to go into the properties of the CHM file and select 'Unblock'. Once that was done, the text showed up just fine.
 
Back
Top