home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a006 / 2.ddi / CEXAM.ZIP / SRCHKEY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-11  |  904 b   |  38 lines

  1. #include <stdio.h>
  2. #include "pxengine.h"
  3.  
  4. #define TABLENAME        "table"
  5. char search[] = "SearchString";
  6.  
  7. int main(void)
  8. {
  9.     TABLEHANDLE tblHandle;
  10.     RECORDHANDLE recHandle;
  11.     FIELDHANDLE fldHandle;
  12.     int pxErr;
  13.     int nFlds = 1;
  14.  
  15.     PXInit();
  16.     PXTblOpen(TABLENAME, &tblHandle, 0, 0);
  17.     PXRecBufOpen(tblHandle, &recHandle);
  18.     PXFldHandle(tblHandle,"Alpha Field",&fldHandle);
  19.     PXPutAlpha(recHandle, fldHandle, search);
  20.  
  21.     /* Search for match on a key */
  22.     if ((pxErr = PXSrchKey(tblHandle, recHandle, nFlds, 
  23.                  SEARCHFIRST)) != PXSUCCESS)
  24.     {   
  25.         if (pxErr == PXERR_RECNOTFOUND)
  26.             printf("No match found\n");
  27.         else
  28.             printf("%s\n",PXErrMsg(pxErr));
  29.     }
  30.     else
  31.         printf("Match found\n");
  32.  
  33.     PXRecBufClose(recHandle);
  34.     PXTblClose(tblHandle);
  35.     PXExit();
  36.     return(pxErr);
  37. }
  38.