Ejemplo n.º 1
0
        public List<string> GetSequences(List<Table> tables)
        {
            var sequences = new List<string>();
            var conn = new CUBRIDConnection(connectionStr);
            conn.Open();

            try
            {
                using (conn)
                {
                    CUBRIDCommand seqCommand = conn.CreateCommand();
                    seqCommand.CommandText = "select [name], class_name from db_serial";
                    var seqReader = (CUBRIDDataReader)seqCommand.ExecuteReader(CommandBehavior.CloseConnection);
                    while (seqReader.Read())
                    {
                        sequences.AddRange(from table in tables where table.Name.ToUpper() == seqReader.GetString(1).ToUpper() select seqReader.GetString(0));
                    }
                }
            }
            finally
            {
                conn.Close();
            }

            return sequences;
        }
Ejemplo n.º 2
0
        public void CreateCommand_Test()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                conn.ConnectionString = DBHelper.connString;
                conn.Open();
                DBHelper.ExecuteSQL("drop table if exists t", conn);

                CUBRIDCommand cmd = conn.CreateCommand();
                cmd.CommandText = "create table t(idx integer)";

                cmd.ExecuteNonQuery();
                int tablesCount = DBHelper.GetTablesCount("t", conn);
                Assert.AreEqual(1, tablesCount);

                //revert the test db
                DBHelper.ExecuteSQL("drop table t", conn);
                LogTestResult();
            }
        }
Ejemplo n.º 3
0
        public List<string> GetSequences(string tablename, string column)
        {
            var sequences = new List<string>();
            var conn = new CUBRIDConnection(connectionStr);
            conn.Open();

            try
            {
                using (conn)
                {
                    CUBRIDCommand seqCommand = conn.CreateCommand();
                    string sqlCmd = String.Format(@"select [name] from db_serial where class_name='{0}' and att_name='{1}'",
                                                tablename,
                                                column);
                    seqCommand.CommandText = sqlCmd;
                    var seqReader = (CUBRIDDataReader)seqCommand.ExecuteReader(CommandBehavior.CloseConnection);
                    while (seqReader.Read())
                    {
                        sequences.Add(seqReader.GetString(0));
                    }
                }
            }
            finally
            {
                conn.Close();
            }

            return sequences;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Test basic SQL statements execution, using parameters
 /// </summary>
 private static void Test_Command_Multiple_CommandText()
 {
   string sqlTablesCount = "select count(*) from db_class";
   int tablesCount, newTableCount;
   using (CUBRIDConnection conn = new CUBRIDConnection())
   {
     conn.ConnectionString = TestCases.connString;
     conn.Open();
     using (CUBRIDCommand cmd = conn.CreateCommand())
     {
       tablesCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
       cmd.CommandText = "create table test(id int)";
       cmd.CommandType = CommandType.Text;
       cmd.ExecuteNonQuery();
       newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
       Debug.Assert(newTableCount == tablesCount + 1);
       cmd.CommandText = "drop table test";
       cmd.CommandType = CommandType.Text;
       cmd.ExecuteNonQuery();
       newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
       Debug.Assert(newTableCount == tablesCount);
     }
   }
 }