Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SQLFetchScroll is failing if database column contains NULL value

SQLFetchScroll is failing if database column contains NULL value

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashish Ranjan Mishra
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • A Ashish Ranjan Mishra

      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

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        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.

        A Offline
        A Offline
        Ashish Ranjan Mishra
        wrote on last edited by
        #3

        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

        R 2 Replies Last reply
        0
        • A Ashish Ranjan Mishra

          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

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          I'd probably try switching 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.

          1 Reply Last reply
          0
          • A Ashish Ranjan Mishra

            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

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Showing a relevant piece of code here might make things easier too.

            "Real men drive manual transmission" - Rajesh.

            A 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Showing a relevant piece of code here might make things easier too.

              "Real men drive manual transmission" - Rajesh.

              A Offline
              A Offline
              Ashish Ranjan Mishra
              wrote on last edited by
              #6

              // 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

              R 1 Reply Last reply
              0
              • A Ashish Ranjan Mishra

                // 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

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups