CreateTable

ODBPPLib.IODBPP.CreateTable creates a new table within the database.
uint CreateTable (
   TableSchema schema
);

Parameters

schemaA valid schema definition for the desired table.

Return Values

CreateTbale will return on successful creation of a table where the schema.tableID was set to zero, the next allocated ID is written to this return value.

Remarks

  • Database must be in exculsive mode before this method is called.
  • CreateTable is atomic and will be undone if method fails.
  • CreateTable checks to see if the given schema is valid, if it is capable of being repaired, it will do it.
  • CreateTable is not part of the transaction so there is no need to call CommitTransaction.
Example Use
  • C#
private void button1_Click(object sender, EventArgs e){
   try{
      OpenFileDialog dlg = new OpenFileDialog();
      DialogResult result = dlg.ShowDialog();
      if (result == DialogResult.OK)
      {
         ODBPPLib.ODBPP odbpp = new ODBPPLib.ODBPP();
         odbpp.CreateDatabase(dlg.FileName);
         odbpp.BeginTransaction(odbpp.EXCLUSIVE, 60000);
         ODBPPLib.TableSchema schema = new ODBPPLib.TableSchema();
         schema.tableName = "First";
         schema.fields.Add(odbpp.UINT32, 0, 0, "First", null);
         schema.fields.Add(odbpp.FLOAT32, 0, 0, "Second", null);
         schema.indexes.Add(0, odbpp.B_TREE, 0, 0, 0, null);
         schema.indexes[0].segments.Add(0, 0);
         tableId = odbpp.CreateTable(schema);
      }
   }
   catch (Exception e1)
   {
      MessageBox.Show(e1.Message);
   }
}

Also See

AddTable, CloseTable, OpenTable, RemoveTable
Comments (0)Listen All
Characters left: 2500
 
Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript