company logo

File access via property handle

Keywords:  file schema

You may access an external file by property handle.This allows reading or writing data from a program or from within an OSI expression. Property handles for external files will not, however, import or export data automatically.

Opening a file via property handle activates property handle functionality for the external files. Although there are many features, which cannot be supported for an external file, many helpful functions of property handle are still working for this data source type.

Accessing external data via property handle does not require an exchange schema. A file schema, which does not define data mapping, would be sufficient. Since file schemata for CSV files can be derived very simple in many cases, the external file does not require additional information for being accessed.

The property handle access functionality is the base for the OSI functions fromFile and toFile , which are used for explicit data exchange.

Property handle file extent

The file schema for external files can be defined in advance within the ODABA dictionary in terms of structure and extent definition. In this case, the external file can simply be accessed via the extent name, similar to any other extents in the database.

The path to the file to be accessed is set in an option with the extent name.

The file type to be accessed has to be defined in the extent definition /access type) as AT_BIN (flat files) or AT_EXTERN for extended self delimiter (ESDF), comma separated (CSV), object interchange format (OIF) and xml files (XML) . One more type supported is directory access ( AT_DIR ) .

Accessing external files via extents is limited in the sense that specific settings as head line option indicating self describing files or special delimiters are not supported. More flexible file access is provided via the openExtern() function, which allows opening a collection based on an external file without referring to definitions in the directory.

Open extern

Often, it is not very comfortable defining structure and property handles for external files in the dictionary. Especially, CSV files often carry metadata in the headline, which contains sufficient information for extracting a file schema. Thus, property handle supports an additional function for opening external data sources, which are not defined in the dictionary. This allows accessing data ad-hoc and in much simpler in many cases.

In order to access external files that do not have a file schema definition at all, ad-hoc schemata can be created for semi-structured files as XML or OIF. In this case, the file is analyzed and a file schema is derived from property names passed with the data.

openExtern (const odaba::ObjectSpace &cObjectSpace, odaba::String sFilePath, odaba::String sDefinitionFile, odaba::String sFileType, odaba::AccessModes eAccessMode, bool bHeadline )

Related topics