Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Batch Commands


When using the CUBRID ADO.NET Data Provider library, you can execute more than one query against the data service in a single batch. For more information, see Batching Operations (ADO.NET Data Services).

For example, in CUBRID you can do:

string[] sql_arr = new string[3];
sql_arr[0] = "insert into t values(1)";
sql_arr[1] = "insert into t values(2)";
sql_arr[2] = "insert into t values(3)";
conn.BatchExecute(sql_arr);

or:

string[] sqls = new string[3];
sqls[0] = "create table t(id int)";
sqls[1] = "insert into t values(1)";
sqls[2] = "insert into t values(2)";
conn.BatchExecuteNoQuery(sqls);

Here is a complete example:

using CUBRID.Data.CUBRIDClient;

namespace BatchExample
{
    class Program
    {
        static void Main(string[] args)
        {
            CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000");
            using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
            {
                conn.Open();
                string[] sqls = new string[4];
                sqls[0] = "drop table if exists t";
                sqls[1] = "create table t(id int)";
                sqls[2] = "insert into t values(1)";
                sqls[3] = "insert into t values(2)";
                conn.BatchExecuteNoQuery(sqls);
                conn.Close();
            }
        }
    }
}
comments powered by Disqus
Page info
viewed 1865 times
translations en
Author
posted 2 years ago by
CUBRID
Contributors
updated last year by
View revisions
Share this article