IMetaRdsLoader.SqlSource

Fore Syntax

SqlSource: String;

Fore.NET Syntax

SqlSource: string;

Description

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

Comments

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

Fore Example

Executing the example requires that repository contains an MDM repository with the RDS_REPO 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 used to create table MDM dictionaries and load data to these dictionaries. 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.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    RdsLoader: IMetaRdsLoader;
Begin
    // Get current repository
    MB := Params.Metabase;
    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.ulmInsert);
End Sub;

See also:

IMetaRdsLoader