In this article:

General Information

Reading and Writing Custom and Binary Fields

Setting Field Value

Reading Field Value

Example

Working with Fields That Have Custom Data Type

Article number: KB000031

General Information

When working with the repository table, on creating new fields the user should specify the data type to be stored in this field. In addition to basic types (String, Integer, Real, Date), one of the custom data types can be specified: Custom, Text or Binary. A certain type of field is created in the physical table on the server, to which this repository table corresponds. The following are the types of physical table fields depending on DBMS in use:

Type of the field in the repository table Oracle Microsoft SQL Server DB2
Custom LONG RAW VARBINARY(MAX) BLOB
Text CLOB (NCLOB when working with Unicode) VARCHAR(MAX) (NVARCHAR(MAX) on working in Unicode) CLOB (NCLOB when working with Unicode)
Binary BLOB VARBINARY(MAX) BLOB

To get supported DBMS version, see the Supported DBMS section.

Text fields are used to store character information. The values of such fields are specified as any character data, which length does not exceed the limit specified for this type of data.

Custom and binary fields are used to store binary data. Streams are used to work with this data type as described below.

Reading and Writing Custom and Binary Fields

Custom and binary fields take link to a stream that contains any data as their value. The stream may be associated with any file or created dynamically in memory. Repository objects that support saving to the stream can also be stored in custom fields. After transaction, stream data is recorded in the repository database. Custom and binary field values are also retrieved in the stream. This is executed by the FromVariant static method of the IOStream class. Data loaded in the stream can be edited and resaved later.

Setting Field Value

Var
    //...
    Fields: IDatasetInstanceFields;
    StreamData: IIOStream;
    //...
Begin
    //...
    Fields.FindById("<Field ID>").Value := StreamData;
    //...

Reading Field Value

Var
    //...
    Fields: IDatasetInstanceFields;
    StreamData: IIOStream;
    //...
Begin
    //...
    StreamData := IOStream.FromVariant(Fields.FindById("<Field ID>").Value);
    //...

Example

Consider an example of writing and reading data in a binary field. To execute the example, create a table with the TImages identifier with the following fields:

Field identifier Field type Brief description
IMG_NAME Text File name.
IMG Binary Image file.

Also create a form as an example. The following components are placed on the form:

When the form is loaded, the table opens and records cache is obtained. Clicking the BPrior and BNext buttons allows for navigating the cache records. Any move in the cache invokes the LoadRecord procedure. This procedure retrieves values of current records fields. An image from the IMG field is loaded in the stream, which contents is loaded in the ImgBox component. Clicking the BAdd button displays the file selection dialog box. After selecting an image file, a new record is added. File name and the file itself are recorded in the table.

Example

To store a repository object in the IMG field, for example a regular report, transform the code above and add the following components to the form:

Example

See also:

Developers Knowledge Base