SQLFetchScroll is failing if database column contains NULL value
-
HI, I am using SQLFetchScroll for bulk reading from DB .But it is failing for some tables loading where columns contain NULL values. Can anyone help me on this to get rid of this? Regards, ASH
asdsa
-
HI, I am using SQLFetchScroll for bulk reading from DB .But it is failing for some tables loading where columns contain NULL values. Can anyone help me on this to get rid of this? Regards, ASH
asdsa
Have you checked the return value to see how it's different from when it succeeds? Have you seen the diagnostics information provided in the documentation page[^]?
"Real men drive manual transmission" - Rajesh.
-
Have you checked the return value to see how it's different from when it succeeds? Have you seen the diagnostics information provided in the documentation page[^]?
"Real men drive manual transmission" - Rajesh.
Yes, Rajesh I have checked the return code is -11072.. I am not able to find any related document for this error code Any help is appreciate.. Thanks, Ashish
asdsa
-
Yes, Rajesh I have checked the return code is -11072.. I am not able to find any related document for this error code Any help is appreciate.. Thanks, Ashish
asdsa
I'd probably try
switch
ing the return value to one of the values documented. The possible return values documented are:SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_ERROR, SQL_INVALID_HANDLE.
Or you could look up the definitions of these return values to see if any of these are defined as -11072."Real men drive manual transmission" - Rajesh.
-
Yes, Rajesh I have checked the return code is -11072.. I am not able to find any related document for this error code Any help is appreciate.. Thanks, Ashish
asdsa
Showing a relevant piece of code here might make things easier too.
"Real men drive manual transmission" - Rajesh.
-
Showing a relevant piece of code here might make things easier too.
"Real men drive manual transmission" - Rajesh.
// NumRowsFetched. SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, sizeof(ORDERINFO), 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, ROW_ARRAY_SIZE, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, RowStatusArray, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0); // Bind elements of the first structure in the array to the OrderID, // SalesPerson, and Status columns. SQLBindCol(hstmt, 1, SQL_C_ULONG, &OrderInfoArray[0].OrderID, 0, &OrderInfoArray[0].OrderIDInd); SQLBindCol(hstmt, 2, SQL_C_CHAR, OrderInfoArray[0].SalesPerson, sizeof(OrderInfoArray[0].SalesPerson), &OrderInfoArray[0].SalesPersonLenOrInd); SQLBindCol(hstmt, 3, SQL_C_CHAR, OrderInfoArray[0].Status, sizeof(OrderInfoArray[0].Status), &OrderInfoArray[0].StatusLenOrInd); // Execute a statement to retrieve rows from the Orders table. SQLExecDirect(hstmt, "SELECT OrderID, SalesPerson, Status FROM Orders", SQL_NTS); // Fetch up to the rowset size number of rows at a time. Print the actual // number of rows fetched; this number is returned in NumRowsFetched. // Check the row status array to print only those rows successfully // fetched. Code to check if rc equals SQL_SUCCESS_WITH_INFO or // SQL_ERRORnot shown. while ((rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0)) != SQL_NO_DATA) {
asdsa
-
// NumRowsFetched. SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, sizeof(ORDERINFO), 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, ROW_ARRAY_SIZE, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, RowStatusArray, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0); // Bind elements of the first structure in the array to the OrderID, // SalesPerson, and Status columns. SQLBindCol(hstmt, 1, SQL_C_ULONG, &OrderInfoArray[0].OrderID, 0, &OrderInfoArray[0].OrderIDInd); SQLBindCol(hstmt, 2, SQL_C_CHAR, OrderInfoArray[0].SalesPerson, sizeof(OrderInfoArray[0].SalesPerson), &OrderInfoArray[0].SalesPersonLenOrInd); SQLBindCol(hstmt, 3, SQL_C_CHAR, OrderInfoArray[0].Status, sizeof(OrderInfoArray[0].Status), &OrderInfoArray[0].StatusLenOrInd); // Execute a statement to retrieve rows from the Orders table. SQLExecDirect(hstmt, "SELECT OrderID, SalesPerson, Status FROM Orders", SQL_NTS); // Fetch up to the rowset size number of rows at a time. Print the actual // number of rows fetched; this number is returned in NumRowsFetched. // Check the row status array to print only those rows successfully // fetched. Code to check if rc equals SQL_SUCCESS_WITH_INFO or // SQL_ERRORnot shown. while ((rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0)) != SQL_NO_DATA) {
asdsa
So, you've pasted here some code from MSDN[^]. If you're trying that sample mentioned in MSDN, do you have a replica of that database on your DB server? How many iterations does the loop run, and what is the value that the call returns each time? And if it's that integer value you mentioned earlier, have you tried looking up the header files to see which valid return type is defined as that number? Please try this, and tell me what you find. And in case you just pasted some random code from MSDN here in the hope that I'll setup a database here and do all the work to figure out what things could go wrong, ... I really don't have to be doing this at 3AM, you know?
"Real men drive manual transmission" - Rajesh.