查找某个表的特定RECID行的主索引字段值

 

static void FindPrimaryIdx(Args _args)

{

     DictTable       dt;

     DictIndex       di;

     Common          cm;

     IndexID         idx;

     int             i, iCnt;

     FieldID         fid;

     FieldID         fids[,10];

     int             fidsCnt = 0;

     str             s;

     str             sTemp;

     int _tID=175,_rID=956968;//可以修改或使用参数传递

 

     ;

     dt  = new DictTable(_tid);

     if (dt) {

         idx = dt.primaryIndex();

         if (idx) {

             di  = dt.indexObject(idx);

             if (di) {

                 iCnt = di.numberOfFields();

                 for (i=1;i<=iCnt;i++) {

                     fid = di.field(i);

                     if (fid) {

                         fidsCnt++;

                         fids[fidsCnt] = fid;

                     }

                 }

             }

         }

         cm = dt.makeRecord();

         select firstonly * from cm

         where cm.RecId == _rid;

         if (cm.RecId) {

             // 找不到记录

             for (i=1;i<=fidscnt;i++) {

                 fid   = fids[i];

                 sTemp = strfmt('[%1]=[%2]',fieldId2Name(_tid, fid),cm.(fid));

                 if (s) s = s+',';

                 s        = s + sTemp;

                 info(s);

             }

         }

     }

 

}

posted @ 2009-04-26 12:08  Fandy Xie  Views(132)  Comments(0Edit  收藏  举报