现在的位置: 首页 > 综合 > 正文

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

2013年09月05日 ⁄ 综合 ⁄ 共 1123字 ⁄ 字号 评论关闭

 

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);

             }

         }

     }

 

}

抱歉!评论已关闭.