Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-539

[ODBC] OdbcDataReader.GetDataTypeName doesn't work

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: ODBC-Apricot
    • Fix Version/s: ODBC-Aprium
    • Component/s: ODBC
    • Labels:
      None
    • Environment:

      OS: Windows XP 32bit
      Server Version:CUBRID 9.1 (9.1.0.0212) (64bit release build for linux_gnu) (Mar 14 2013 00:16:33)
      Driver Version: ODBC driver 9.1 (20130422-14175366)

      Description

      • Brief:
        • The OdbcDataReader.GetDataTypeName doesn't work properly, it always return null value
      • Test Code:
         
                [Test, Description("Test for DdbcDataReader GetDataTypeName Method")]
                public void OdbcDataReaderMethod_GetDataTypeName()
                {
                    // Open Connection
                    string strConn = @"Driver={CUBRID Driver};db_name=odbc_test;uid=dba;pwd=;server=10.34.64.57;port=33037;fetch_size=100";
                    OdbcConnection connCubrid = new OdbcConnection(strConn);
                    connCubrid.Open();
        
                    // Create a test table with 4 columns in various data type
                    string testTable = "table_data_type";
                    string strDropTable = string.Format("DROP TABLE {0}", testTable);
                    string strCreateTable = string.Format(@"CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
                                                   col_1 INT, col_2 VARCHAR, col_3 CHAR)", testTable);
                    string strSqlInsert = string.Format("INSERT INTO {0}(col_1, col_2, col_3) VALUE(123, 'varchar contents', 'a')", testTable);
        
                    // Execute multiple queries
                    ExecuteMultiQueries(connCubrid, new string[] {strDropTable, strCreateTable, strSqlInsert});
        
                    string strSqlSelect = string.Format("SELECT * FROM {0} ORDER BY id DESC;", testTable);
                    OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect);
        
                    // Check for GetDataTypeName returned values
                    Assert.AreEqual("INT", odbcReader.GetDataTypeName(0));
                    Assert.AreEqual("INT", odbcReader.GetDataTypeName(1));
                    Assert.AreEqual("VARCHAR", odbcReader.GetDataTypeName(2));
                    Assert.AreEqual("CHAR", odbcReader.GetDataTypeName(3));
                    connCubrid.Close();
                }
        
                private OdbcDataReader CreateReader(OdbcConnection conn, string query)
                {
                    OdbcCommand command = new OdbcCommand();
                    command.Connection = conn;
                    command.CommandText = query;
                    OdbcDataReader odbcReader = command.ExecuteReader();
                    odbcReader.Read();
                    return odbcReader;
                }
        
                private void ExecuteMultiQueries(OdbcConnection conn, string[] multiQueries)
                {
                    OdbcCommand command = new OdbcCommand();
                    command.Connection = conn;
                    foreach (string query in multiQueries)
                    {
                        try
                        {
                            command.CommandText = query;
                            command.ExecuteNonQuery();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                    command.Dispose();
                }
        
        
      • Result:
        • Expected Results: "INT, INT, VARCHAR, CHAR"
        • Real Results: null, null, null. null

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -


        When parameter of function SQLColAttribute is SQL_DESC_TYPE_NAME,we should return value of type name, But the function return null,now.

        Show
        cn15800 谢韦华[Bert] added a comment - When parameter of function SQLColAttribute is SQL_DESC_TYPE_NAME,we should return value of type name, But the function return null,now.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        The result as follow:

        INTEGER
        INTEGER
        VARCHAR
        CHAR
        请按任意键继续. . .

        The driver will return INTEGER when data type is int.

        Show
        cn15800 谢韦华[Bert] added a comment - The result as follow: INTEGER INTEGER VARCHAR CHAR 请按任意键继续. . . The driver will return INTEGER when data type is int.
        Hide
        ryin005 Ray Yin added a comment -

        Fixed on ODBC-9.1.0 (20130502-17531383)

        Show
        ryin005 Ray Yin added a comment - Fixed on ODBC-9.1.0 (20130502-17531383)

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            ryin005 Ray Yin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: