1 static void FindPrimaryIdx(Args _args)
2 {
3 DictTable dt;
4 DictIndex di;
5 Common cm;
6 IndexID idx;
7 int i, iCnt;
8 FieldID fid;
9 FieldID fids[,10];
10 int fidsCnt = 0;
11 str s;
12 str sTemp;
13 int _tID=175,_rID=956968;//可以修改或使用参数传递
14 ;
15
16 dt = new DictTable(_tid);
17 if (dt)
18 {
19 idx = dt.primaryIndex();
20 if (idx) {
21 di = dt.indexObject(idx);
22 if (di) {
23 iCnt = di.numberOfFields();
24 for (i = 1; i <= iCnt; i++) {
25 fid = di.field(i);
26 if (fid) {
27 fidsCnt++;
28 fids[fidsCnt] = fid;
29 }
30 }
31 }
32 }
33 cm = dt.makeRecord();
34 select firstonly * from cm
35 where cm.RecId == _rid;
36 if (cm.RecId) {
37 // 找不到记录
38 for (i = 1; i <= fidscnt; i++) {
39 fid = fids[i];
40 sTemp = strfmt('[%1]=[%2]',fieldId2Name(_tid, fid),cm.(fid));
41 if (s) s = s+',';
42 s = s + sTemp;
43 info(s);
44 }
45 }
46 }
47 }