IDalCommandParam.DataDomain

Fore Syntax

DataDomain: DbDataDomain;

Fore.NET Syntax

DataDomain: Prognoz.Platform.Interop.DbDataDomain;

Description

The DataDomain property determines a parameter data type if the parameter is used to transfer 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 execution, the character length is checked if it can be inserted as the character field value. The limit for these fields is 3999 characters. If a text field is created in the table for which the query is executed, disable the value length check for inserting a value exceeding 3999 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 the example requires a table with the TFILESTORE physical name at the database 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 contents of file in text form
    FileStr := File.Open("c:\1.txt", FileOpenMode.Read, FileShare.DenyNone);
    TextRead := New TextReader.Create(FileStr);
    TextFile := TextRead.ReadToEnd;
    //Set parameter values
    Param.Value := FileStr.FileName;
    //Write file text without checking length of transferred data
    Param1.DataDomain := DbDataDomain.Memo;
    Param1.Value := TextFile;
    //Execute command
    Com.Execute;
    Com.Close;
    Dispose TextRead;
End Sub UserSub;

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

Fore.NET Example

Execute the example requires a table with the TFILESTORE physical name at the database 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 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 contents of file in text form
    FileStr := FileClass.Open("c:\1.txt", FileOpenMode.frRead, FileShare.frDenyNone);
    TextRead.Create(FileStr);
    TextFile := TextRead.ReadToEnd();
    //Set parameter values
    Param.Value := FileStr.FileName;
    //Write file text without checking length of transferred data
    Param1.DataDomain := DbDataDomain.dddMemo;
    Param1.Value := TextFile;
    //Execute command
    Com.Execute();
    Com.Close();
End Sub;

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

See also:

IDalCommandParam