Create an index for a TClientDataSet at runtime

简介: I had originally created the index with the property IndexName and finally found out that this did not select my index.

I had originally created the index with the property IndexName
and finally found out that this did not select my index.
Selecting the index by the property IndexFieldNames worked fine,
as the following source shows.

This is also an example how to create a memory table.. 
   
  with CDS1 Do
  begin
    Close;
    // Define the fields
    FieldDefs.Clear;
    FieldDefs.Add ('Project', ftInteger, 0, True);
    FieldDefs.Add ('Module',  ftString, 60, False);
    FieldDefs.Add ('FuncName',ftString, 60, False);
    FieldDefs.Add ('FuncDate',ftDate,    0, False);
    FieldDefs.Add ('FuncCRC', ftString,  2, False);
    FieldDefs.Add ('Programmer', ftString, 32, False);
    // Define the index
    IndexDefs.Clear;
    IndexDefs.Add ('IProject', 'Project;Module;FuncName',
                   [ixPrimary, ixUnique]);
    // this seems not to do anything
    IndexName := 'IProject';

    // this does work
    IndexFieldNames := 'Project;Module;FuncName';

    // Create the dataset
    CreateDataSet;
    Open;
  end;

目录
相关文章
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
414 0
|
存储 网络协议 网络安全
MQTTClient_create函数
MQTTClient_create函数
362 0
|
8月前
|
存储
Build desc failed:Fetch table group shards failed on meta proxy:Loading cached shard 1ocation value for table group[dwhg_scm.dwhg_prd_tg_default] failed
Build desc failed:Fetch table group shards failed on meta proxy:Loading cached shard 1ocation value for table group[dwhg_scm.dwhg_prd_tg_default] failed
218 2
|
Unix Java Linux
Runtime.exec方法之获取process id
Runtime.exec方法之获取process id
230 0
|
JavaScript 索引
js中exec,test,match,search,split等方法的使用
exec:对string进行正则处理,并返回匹配结果.array[0]为原字符串,array[i]为匹配在整个被搜索字符串中的位置。 test:测试string是否包含有匹配结果,包含返回true,不包含返回false。
85 0
Cannot add task ‘wrapper‘ as a task with that name already exists.
Cannot add task ‘wrapper‘ as a task with that name already exists.
208 0
|
Spring Java 数据库连接
DataSourceBuilder.create().build()
Spring Boot also provides a utility builder class DataSourceBuilder that can be used to create one of the standard data sources (if it is on the classpath).
5599 0