company logo

Access functions

External files can be accessed in different ways.

  • File - Read or write explicitly
  • FromFile - Import from file
  • ToFile - Export to file

Depending on the required functionality, a file schema and a data exchange schema should be provided.

File

The File() operation allows accessing an external file structure, which is defined by an explicit or implicit file schema. External files can be read or written, but depending on the file structure, there are several restrictions. Most external file formats do support appending data to the file, only.

External data sources can be accessed in OSI script files or access path via the File() operation, but also via property handle.

// OSI or access path

VARIABLES

  set<VOID>  &extFile = File( Path='c:/temp/my_persons.xml', FileType='xml',

                               Definition='c:/temp/my_persons.def', Headline = false);

PROCESS

  while ( extFile.next )

//    ... processing;

// C++ property handle

  Property     extFile;

  extFile.openExtern(os,"c:/temp/my_persons.xml","c:/temp/my_persons.def",

                     'xml',false);

  while ( extFile.next() )

//    ... processing;

FromFile

The FromFile() operation supports importing data from external files into a database. Importing files requires a (usually explicit) data exchange schema (extended file schema), which provides a mapping to database locations in addition to the structure definition of the import file.

Data can be imported in an OSI script, but also directly in an application program via ODABA API functions. Calling import() with the property handle requires a self-contained import file, i.e. the data exchange schema must be part of the import file. In order to import data for files with a separate exchange schema, an operation path can be used, which is more flexible, since it allows defining different locations for the exchange schema.

// Import external data to extent Persons

// OSI version

  Persons.FromFile( Path='c:/temp/my_persons.xml', FileType='xml',

                    Definition='c:/temp/my_persons.def', Headline = false);

// C++ version

  Property     persons(os,"Persons",Update);

  persons.import("c:/temp/my_persons.oif");

  

// C++ operation path version

  Property     persons(os,"Persons",Update);

  Property     impPh(persons,

                     "Path='c:/temp/my_persons.xml', FileType='xml',   \

                      Definition='c:/temp/my_persons.def', Headline = false");

  impPh.execute();

ToFile

The ToFile() operation supports exporting data from a database to an external file format. As well as the FromFile() operation, ToFile() requires a data exchange schema.

Data can be exported in an OSI script, but also directly in an application program via ODABA API functions. Calling export() with the property handle requires a self-contained export file, i.e. the data exchange schema must be part of the export file. In order to export data for files with a separate exchange schema, an operation path can be used, which is more flexible, since it allows defining different locations for the exchange schema.

// Import external data to extent Persons

// OSI version

  Persons.ToFile( Path='c:/temp/my_persons.xml', FileType='xml',

                  Definition='c:/temp/my_persons.def', Headline = false);

// C++ version: export Persons to an OIF file

  Property     persons(os,"Persons",Update);

  persons.export("c:/temp/my_persons.oif");

  

// C++ operation path version

  Property     persons(os,"Persons",Update);

  Property     expPh(persons,

                     "Path='c:/temp/my_persons.xml', FileType='xml',   \

                      Definition='c:/temp/my_persons.def', Headline = false");

  expPh.execute();