IDalCommandParam.DataDomain

Fore Syntax

DataDomain: DbDataDomain;

Fore.NET Syntax

DataDomain: Prognoz.Platform.Interop.DbDataDomain;

Description

The DataDomain property determines the parameter data type if the parameter is used to transmit multibyte information.

Comments

In the current implementation this property is relevant if the parameter is used to change the text field value.

When the character value is set in the Value property at the SQL query runtime, the character length is checked whether it can be inserted as the character field value. The limit for these fields is 3,999 characters. If a text field is created in the table for which the query is run, disable the value length check for inserting a value exceeding 3,999 characters by specifying the DbDataDomain.Memo value in the DataDomain property. Text fields can store up to four gigabytes of character data.

Fore Example

Executing this example requires a table with the TFILESTORE physical name on the DB server. This table has two fields: the NAME character field and the TEXT_FILE text field. The root directory of the C disk has the 1.txt file.

Sub UserSub;
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Com: IDalCommand;
    Params: IDalCommandParams;
    Param, Param1: IDalCommandParam;
    FileStr: IFileStream;
    TextRead: ITextReader;
    TextFile: String;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("BD").Open(NullAs IDatabaseInstance;
    Com := DB.Connection.CreateCommand("insert into TFILESTORE (NAME, TEXT_FILE) values(:A, :B)");
    Com.Parse;
    Params := Com.Params;
    Param := Params.Item(0);
    Param1 := Params.Item(1);
    //Read the content of the file in the text form
    FileStr := File.Open("c:\1.txt", FileOpenMode.Read, FileShare.DenyNone);
    TextRead := New TextReader.Create(FileStr);
    TextFile := TextRead.ReadToEnd;
    //Set the parameters values
    Param.Value := FileStr.FileName;
    //Write the file text without checking the length of transmitted data
    Param1.DataDomain := DbDataDomain.Memo;
    Param1.Value := TextFile;
    //Run the command
    Com.Execute;
    Com.Close;
    Dispose TextRead;
End Sub UserSub;

On executing this example the SQL command is executed that inserts a new record in the table. The file name and its content in a character form are passed as the field values. The file content is inserted in the text field. Since the content length can have a great value, to disable the length check, specify the DataDomain property value.

Fore.NET example

To execute this example, the DB server should have a table with the TFILESTORE physical name. This table has two fields: the NAME character field and the TEXT_FILE text field. The root directory of the C disk has the 1.txt file.

Sub UserProc();
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Com: IDalCommand;
    Params: IDalCommandParams;
    Param, Param1: IDalCommandParam;
    FileClass: FileClass = New FileClass();
    FileStr: IFileStream;
    TextRead: TextReaderClass = New TextReaderClass();
    TextFile: String;
Begin
    MB := Self.Metabase;
    DB := MB.ItemById["BD"].Open(NullAs IDatabaseInstance;
    Com := DB.Connection.CreateCommand("insert into TFILESTORE (NAME, TEXT_FILE) values(:A, :B)");
    Com.Parse();
    Params := Com.Params;
    Param := Params.Item[0];
    Param1 := Params.Item[1];
    //Read the content of the file in the text form
    FileStr := FileClass.Open("c:\1.txt", FileOpenMode.frRead, FileShare.frDenyNone);
    TextRead.Create(FileStr);
    TextFile := TextRead.ReadToEnd();
    //Set the parameters values
    Param.Value := FileStr.FileName;
    //Write the file text without checking the length of transmitted data
    Param1.DataDomain := DbDataDomain.dddMemo;
    Param1.Value := TextFile;
    //Run the command
    Com.Execute();
    Com.Close();
End Sub;

On executing this example the SQL command is executed that inserts a new record in the table. The file name and its content in a character form are passed as the field values. The file content is inserted in the text field. Since the content length can have a great value, to disable the length check, specify the DataDomain property value.

See also:

IDalCommandParam