IMetaRdsLoader.SqlSource

Syntax

SqlSource: String;

Description

The SqlSource property determines an SQL query, executing of which creates a data source for an MDM dictionary.

Comments

The specified query is executed to extract data on executing the IMetaRdsLoader.Load method.

Example

Executing the example requires that the repository contains a folder with the MDM identifier and a table with the T_Dictionary physical name. The table must contain the following fields: KEY (integer), NAME (string), ORD (integer).

Add links to the system assemblies: Dt, Metabase, Rds.

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    RdsLoader: IMetaRdsLoader;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.Parent := MB.ItemById("MDM");
    CrInfo.Id := MB.GenerateId("NewSQLDictionary", CrInfo.Parent.Key);
    // Create object to create table MDM dictionary and to load data to it
    RdsLoader := New MetaRdsLoader.Create;
    RdsLoader.SqlSource := "Select ""KEY"", ""NAME"", ""ORD"" From  T_Dictionary";
    //Binding of attributes
    RdsLoader.Bindings.KeyBinding.Field := "KEY";
    RdsLoader.Bindings.NameBinding.Field := "NAME";
    RdsLoader.Bindings.OrderBinding.Field := "ORD";
    //Dictionary creation
    (RdsLoader.CreateObject(CrInfo) As IMetabaseObject).Save;
    //Data loading
    RdsLoader.Load(UpdateLoadMode.Insert);
End Sub UserProc;

Executing the example initializes the object that is used to create MDM dictionaries and to load data to them. To create a dictionary, bindings to the source field, which is SQL request, will be set up. After that a dictionary is created, and the data,obtained on executing the SQL request, is loaded to the dictionary.

See also:

IMetaRdsLoader