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

"query1" + "query2" doesn't work

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: ADO.NET 9.2.0.0002
    • Component/s: ADO.NET
    • Labels:
      None

      Description

      http://www.cubrid.com/zbxe/bbs_developer_qa/549207
      A user reported:

      I am coding C# application using ADO.net driver.

      string sQuery = "insert into table_name(c1,c2) values ('aaa', 'bbb');"

      + "insert into table_name(c1,c2) values('ccc','ddd');";

      dbComm.CommandText = sQuery;

      dbComm.CommandType = CommandType.Text;

      dbComm.ExcuteNonQuery();

      Then only the 1st INSERT statement works correctly so that data by 1st INSERT is populated into a DB.
      Do I have to use multi INSERT statement as
      values ('aaa','bbb'), ('ccc','ddd');
      ?

      Is it a bug? Is there any way to execute more than 2 queries with "+" ?

        Activity

        Hide
        kevinyang Kai Yang (Inactive) added a comment -

        Execute the same statement using CSQL application, the two INSERT statement works correctly.

        Show
        kevinyang Kai Yang (Inactive) added a comment - Execute the same statement using CSQL application, the two INSERT statement works correctly.
        Hide
        kevinyang Kai Yang (Inactive) added a comment - - edited

        You can use the following SQL statement to insert multiple data:
        insert into table_name (c1, c2, c3) values ('1', '2','3'),('a', 'b','c'),('!', '@', '#');

        And also you can using CUBRIDConnection BatchExecuteNoQuery or BatchExecute function:
        Sample Code:
        CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000");
        using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
        {
        string[] sqls = new string[3];
        sqls[0] = "insert into table_name (c1, c2, c3) values ('1', '2','3')";
        sqls[1] = "insert into table_name (c1, c2, c3) values ('a', 'b','c')";
        sqls[2] = "insert into table_name (c1, c2, c3) values ('!', '@', '#')";
        conn.BatchExecuteNoQuery(sqls);
        }

        Show
        kevinyang Kai Yang (Inactive) added a comment - - edited You can use the following SQL statement to insert multiple data: insert into table_name (c1, c2, c3) values ('1', '2','3'),('a', 'b','c'),('!', '@', '#'); And also you can using CUBRIDConnection BatchExecuteNoQuery or BatchExecute function: Sample Code: CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000"); using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString())) { string[] sqls = new string [3] ; sqls [0] = "insert into table_name (c1, c2, c3) values ('1', '2','3')"; sqls [1] = "insert into table_name (c1, c2, c3) values ('a', 'b','c')"; sqls [2] = "insert into table_name (c1, c2, c3) values ('!', '@', '#')"; conn.BatchExecuteNoQuery(sqls); }
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited
        {code}
        test code

        public void apis_669()
        {
        String sql = "select s_name from code;select * from test_cubrid;";

        CUBRIDCommand cmd = new CUBRIDCommand(sql, conn);

        CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader();

        while (reader.Read())
        { Console.WriteLine(reader.GetString(0)); };

        while (reader.NextResult())
        {
        Console.WriteLine("=============================");

        while (reader.Read())
        { Console.WriteLine(reader.GetString(0)); Console.WriteLine(reader.GetString(1)); };
        }
        }
        {code}
        Show
        cn15800 谢韦华[Bert] added a comment - - edited {code} test code public void apis_669() { String sql = "select s_name from code;select * from test_cubrid;"; CUBRIDCommand cmd = new CUBRIDCommand(sql, conn); CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader.GetString(0)); }; while (reader.NextResult()) { Console.WriteLine("============================="); while (reader.Read()) { Console.WriteLine(reader.GetString(0)); Console.WriteLine(reader.GetString(1)); }; } } {code}
        Hide
        ryin005 Ray Yin added a comment - - edited

        Test will be failed if the first query only returns one record

        Test Code:
        scenario1:

        {code}
        String sql = "select s_name from code where s_name='X'; select name from nation where name='Algeria';";
        CUBRIDCommand cmd = new CUBRIDCommand(sql, conn);

        CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader();

        while (reader.Read())
        {
        Console.WriteLine(reader.GetString(0));
        };

        while (reader.NextResult())
        {
        Console.WriteLine("=============================");

        while (reader.Read())
        { Console.WriteLine(reader.GetString(0)); };
        }{code}

        Expected result

        X
        =============================
        Algeria
        

        Actualresult

        =============================
        Algeria
        

        Reopen the issue

        Show
        ryin005 Ray Yin added a comment - - edited Test will be failed if the first query only returns one record Test Code: scenario1: {code} String sql = "select s_name from code where s_name='X'; select name from nation where name='Algeria';"; CUBRIDCommand cmd = new CUBRIDCommand(sql, conn); CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader.GetString(0)); }; while (reader.NextResult()) { Console.WriteLine("============================="); while (reader.Read()) { Console.WriteLine(reader.GetString(0)); }; }{code} Expected result X ============================= Algeria Actualresult ============================= Algeria Reopen the issue
        Hide
        ryin005 Ray Yin added a comment -
        • Test OS: Win 32/64
        • CUBRID: 9.2.0.0155
        • Driver: cubrid-ado.net 2013-11-08
        • Framework: .NET3.5/.NET4.0

        Test Result: Pass

        The issue could be closed

        Show
        ryin005 Ray Yin added a comment - Test OS: Win 32/64 CUBRID: 9.2.0.0155 Driver: cubrid-ado.net 2013-11-08 Framework: .NET3.5/.NET4.0 Test Result: Pass The issue could be closed

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            cottonspan Laura Oh
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: