Data Extraction

The IDatasetInstance interface is implemented to work with the data of any relational source of repository. The output data set represents an array of strings. Each string of the array is separate record in a data source, containing values of all fields. For receiving output data set, corresponding object of a repository should be opened using the IMetabaseObjectDescriptor.Open, or IMetabaseObjectDescriptor.OpenWithParam methods and cast it to the IDatasetInstance interface:

Sub UserProc;
Var
    MB: IMetabase;
    DSInst: IDatasetInstance;
    FieldsDefs: IDatasetModelFields;
    FieldsDef: IDatasetModelField;
    FieldsInst: IDatasetInstanceFields;
    FieldInst: IDatasetInstanceField;
Begin
    MB := MetabaseClass.Active;
    DSInst := MB.ItemById("Table_1").Open(NullAs IDatasetInstance;
    //List of fields
    FieldsDefs := DSInst.FieldDefs;
    For Each FieldsDef In FieldsDefs Do
        Debug.Write(FieldsDef.Id + " ");
    End For;
    Debug.WriteLine("");
    //Values of all records
    While Not DSInst.Eof Do
        FieldsInst := DSInst.Fields;
        For Each FieldInst In FieldsInst Do
            Debug.Write(FieldInst.Value + " ");
        End For;
        Debug.WriteLine("");
        DSInst.Next;
    End While;
End Sub UserProc;

After executing the example, data of table Table_1 is obtained. The list of fields and values of all records are displayed in the console of the development environment.

See also:

Examples