Uploaded image for project: 'Apache Trafodion (Retired)'
  1. Apache Trafodion (Retired)
  2. TRAFODION-2633

SQLFetch didn't fetch expected result when converting from SQL_TINYINT to SQL_C_NUMERIC

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2.0
    • None
    • None

    Description

      please see below code segment, after SQLFetch buf2 expected result:
      {precision = 0x3, scale = 0x0, sign = 0x0, val = {0x80, 0x0 <repeats 15 times>}} ,
      Actual:
      {precision = 0x3, scale = 0x0, sign = 0x2, val = {0x0 <repeats 15 times>, 0x80}}

      void test(SQLHANDLE hstmt)
      {
      SQLRETURN retcode;
      SQL_NUMERIC_STRUCT buf;
      SQL_NUMERIC_STRUCT buf2;
      memset(&buf, '\0', sizeof(SQL_NUMERIC_STRUCT));
      memset(&buf2, '\0', sizeof(SQL_NUMERIC_STRUCT));
      buf.precision = 3;
      buf.scale = 0;
      buf.sign = 0;
      buf.val[0] = 128;

      SQLLEN len = SQL_NTS;
      SQLSMALLINT nc = 0;

      int id = 1;
      retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &id, 0, &len);
      check(retcode, "SQLBindParameter", SQL_HANDLE_STMT, hstmt);
      len = SQL_NTS;
      retcode = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_NUMERIC, SQL_TINYINT, 0, 0, &buf, sizeof(SQL_NUMERIC_STRUCT), &len);
      check(retcode, "SQLBindParameter", SQL_HANDLE_STMT, hstmt);

      char *sqls[] =

      { "DROP TABLE TB_TEST", "CREATE TABLE TB_TEST(ID INT, C TINYINT)", "INSERT INTO TB_TEST VALUES(?,?)", "SELECT * FROM TB_TEST", "END_LOOP" }

      ;

      for (int i = 0; strcmp(sqls[i], "END_LOOP"); ++i)

      { retcode = SQLExecDirect(hstmt, (SQLCHAR*)sqls[i], SQL_NTS); check(retcode, sqls[i], SQL_HANDLE_STMT, hstmt); }

      retcode = SQLNumResultCols(hstmt, &nc);
      check(retcode, "SQLNumResultCols", SQL_HANDLE_STMT, hstmt);

      retcode = SQLBindCol(hstmt, 2, SQL_C_NUMERIC, &buf2, sizeof(buf2), &len);
      check(retcode, "SQLBindCol", SQL_HANDLE_STMT, hstmt);

      retcode = SQLFetch(hstmt);
      check(retcode, "SQLFetch", SQL_HANDLE_STMT, hstmt);
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sujinpei 苏锦佩
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: