OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME

 

Adding data to your database

Single fields

Adding data to a single field is just the same as adding data to a variable -> you assign the value to the field by specifying the field on the LHS and the value on the RHS of the assignment operator. For example:

	People.field1 = value1;  

Whole table

This  is covered in the copying/cloning page.


saveRecord()

Data is lazily instantiated in OOFILE -> this means that the data is put in cache until it absolutely has to save it (this reduces processing). If you wish to make the record's information permanent, you must declare saveRecord(). For example:

mytable.saveRecord();

Note: OOFILE can run in two modes. There is the automaticSave mode (in which you don't HAVE to specify saveRecord() and the requireExplicit mode (generally used as default as it then catches errors). The requireExplicit mode reuires you to use saveRecord(). If you don't it will return an error message.


Adding via method in table class

 


Adding via stream

This is related to the use of the operator>>.  We can initialise a record by parsing through a stream of data for the fields we require. For now we need to specify the format of the stream for example by setting the field to be delimited by tabs. The sample in ooftst10 gives a basic rundown of this technique, simulating an input stream by first creating an output stream and passing values into that. This is then passed to an output stream that is finally passed into the actual record using the operator>>. Usually, we would just have a file that contains the record data and use this to pass the data into our table.


Adding from a file

 

Incompatible schema

 


Related data

Adding related data is little different from adding simple field data. The only differrence is that we must specify the field by declaring the traversal path (the way in which we can reach the actual field through the other table) on the LHS. For example:

	Patients.Doctor->LastName = "Li"  

The field LastName is related to the record we are dealing with. The second table is likely to be a table of the doctors at a particular hospital and each doctor has a record with the name and some other details.


Copying one database to another

This is covered in the copying/cloning page.


Examples for adding data
Adding multiple records at once (eg test data) ooftst01.h
Adding related data ooftst02.h
Adding text to a text field using += ooftst28
Copying the data from one database into another ooftst37
From file to a table with extra fields ooftst41
From file to a table with incorrect field sizes ooftst41
From file to a table with unspecified fields/sizes ooftst41
From streams ooftst10
Modifying related data ooftst06
Transfer of data in memory using adoptBody() ooftst31

Feature index

(c) Copyright A.D. Software 1994-2000 (All Rights Reserved).
Last Updated: 9th September 2001