CUBRID Collections


Collections are a specific CUBRID data type(s). If you are not familiar with them, you can read more here: http://www.cubrid.org/manual/841/en/Collection%20Types.

Because collections are not common to any database, but only to CUBRID, the support for them is implemented in some specific CUBRID Collection methods:

public void AddElementToSet(CUBRIDOid oid, String attributeName, Object value)
public void DropElementInSet(CUBRIDOid oid, String attributeName, Object value)
public void UpdateElementInSequence(CUBRIDOid oid, String attributeName, int index, Object value)
public void InsertElementInSequence(CUBRIDOid oid, String attributeName, int index, Object value)
public void DropElementInSequence(CUBRIDOid oid, String attributeName, int index)
public int GetCollectionSize(CUBRIDOid oid, String attributeName)

Here below are two examples of using these CUBRID extensions.
Reading values from a Collection data type:

using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
{
using (DbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
object[] o = (object[])reader0;
for (int i = 0; i <SeqSize; i++)
{
//...
}
}
}
}

Updating a Collection data type:

conn.InsertElementInSequence(oid, attributeName, 5, value);
SeqSize = conn.GetCollectionSize(oid, attributeName);
using (CUBRIDCommandcmd = newCUBRIDCommand("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[])reader0;
}
}
}
conn.DropElementInSequence(oid, attributeName, 5);
SeqSize = conn.GetCollectionSize(oid, attributeName);

Trackback '2'

CUBRID ADO.NET Tutorials

Latest AnnouncementsCUBRID ADO.NET Driver Stable 1.0 version has been released Official ADO.NET Driver for CUBRID is now available Installation Instructions [C...

5 days ago

CUBRID ADO.NET Tutorials

Latest AnnouncementsCUBRID ADO.NET Driver Stable 1.0 version has been released Official ADO.NET Driver for CUBRID is now available Installation Instructions [C...

3 months ago

Page info
viewed 208 times
translations en
Author
posted 4 months ago by
CUBRID
Contributors
updated 3 months ago by
View revisions
Share this article