internal ResultInfo(CUBRIDStatementType stmtType, int resultCount, CUBRIDOid oid, int cacheTimeSec, int cacheTImeUsec) { StmtType = stmtType; ResultCount = resultCount; Oid = oid; CacheTimeSec = cacheTimeSec; CacheTimeUsec = cacheTImeUsec; }
internal ResultInfo(CUBRIDStatementType stmtType, int resultCount, CUBRIDOid oid, int cacheTimeSec, int cacheTImeUsec) { StmtType = stmtType; ResultCount = resultCount; Oid = oid; CacheTimeSec = cacheTimeSec; CacheTimeUsec = cacheTImeUsec; }
/// <summary> /// Test CUBRIDOid class (which implements OID support) /// </summary> private static void Test_Oid_Basic() { using (CUBRIDConnection conn = new CUBRIDConnection()) { conn.ConnectionString = TestCases.connString; conn.Open(); CUBRIDOid oid = new CUBRIDOid("@620|1|0"); Debug.Assert(oid.Page() == 620); Debug.Assert(oid.Slot() == 1); Debug.Assert(oid.Volume() == 0); } }
/// <summary> /// Test CUBRIDDataReader GetOid() method /// </summary> private static void Test_OID_Get() { using (CUBRIDConnection conn = new CUBRIDConnection()) { conn.ConnectionString = TestCases.connString; conn.Open(); string sql = "select * from nation limit 1"; using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn)) { using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader()) { reader.Read(); CUBRIDOid oid = reader.GetOid(); Debug.Assert(oid.ToString() == "OID:@0|0|0"); } } } }
/// <summary> /// Test SEQUENCE operations /// </summary> private static void Test_SequenceOperations() { using (CUBRIDConnection conn = new CUBRIDConnection()) { conn.ConnectionString = TestCases.connString; conn.Open(); TestCases.ExecuteSQL("DROP TABLE IF EXISTS t", conn); //Create a new table with a sequence TestCases.ExecuteSQL("CREATE TABLE t(seq SEQUENCE(int))", conn); //Insert some data in the sequence column TestCases.ExecuteSQL("INSERT INTO t(seq) VALUES({0,1,2,3,4,5,6})", conn); CUBRIDOid oid = new CUBRIDOid("@0|0|0"); using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT t FROM t", conn)) { using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { oid = (CUBRIDOid)reader[0]; } } } String attributeName = "seq"; int value = 7; int SeqSize = conn.GetCollectionSize(oid, attributeName); Debug.Assert(SeqSize == 7); conn.UpdateElementInSequence(oid, attributeName, 1, value); SeqSize = conn.GetCollectionSize(oid, attributeName); Debug.Assert(SeqSize == 7); using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn)) { using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int[] expected = { 7, 1, 2, 3, 4, 5, 6 }; object[] o = (object[])reader[0]; for (int i = 0; i < SeqSize; i++) { Debug.Assert(Convert.ToInt32(o[i]) == expected[i]); } } } } conn.InsertElementInSequence(oid, attributeName, 5, value); SeqSize = conn.GetCollectionSize(oid, attributeName); Debug.Assert(SeqSize == 8); using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn)) { using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int[] expected = { 7, 1, 2, 3, 7, 4, 5, 6 }; object[] o = (object[])reader[0]; for (int i = 0; i < SeqSize; i++) { Debug.Assert(Convert.ToInt32(o[i]) == expected[i]); } } } } conn.DropElementInSequence(oid, attributeName, 5); SeqSize = conn.GetCollectionSize(oid, attributeName); Debug.Assert(SeqSize == 7); using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn)) { using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int[] expected = { 7, 1, 2, 3, 4, 5, 6 }; object[] o = (object[])reader[0]; for (int i = 0; i < SeqSize; i++) { Debug.Assert(Convert.ToInt32(o[i]) == expected[i]); } } } } TestCases.ExecuteSQL("DROP t", conn); } }