home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / viper092.zip / SEARCHKY.CMD < prev    next >
OS/2 REXX Batch file  |  1995-09-20  |  1KB  |  54 lines

  1. /*      VIPER Database Engine
  2.         Search using RxViperSearchKey example.
  3.         Copyright (c) - 1995 by Douglas A. Bebber
  4. */
  5.  
  6.  
  7. /* Register the VIPER Database Engine functions... */
  8. rc = RxFuncAdd("SysLoadViperFuncs","Viper", "SysLoadViperFuncs")
  9. call SysLoadViperFuncs
  10.  
  11. /* OPEN THE DATABASE */
  12. status = RxViperOpenDatabase('CUSTOMER', 'LNAME')
  13. if status = 0 then
  14. Do
  15.         say 'Failed to open CUSTOMER database using the LNAME index!'
  16.         exit
  17. End
  18. else
  19.         say 'Successfully opened CUSTOMER database using the LNAME index!'
  20.  
  21.  
  22. /* Using the LNAME index which has 2 key fields (Last Name, and First Name):  */
  23. SearchKey.0 = 2
  24. SearchKey.1 = 'Doe'     /* Last name to search for */
  25. SearchKey.2 = 'John'    /* First name to search for */
  26.  
  27. status = RxViperSearchKey('CUSTOMER', 'LNAME', SearchKey.)
  28. if status = 0 then
  29.         say 'SearchKey function failed!'
  30. if status = 1 then
  31.         say 'Found the record!'
  32. if status = 2 then
  33.         say 'Record not found, database cursor moved to nearest record meeting search criteria!'
  34.  
  35. /* GET THE RECORD AND DISPLAY IT */
  36. status = RxViperGetRecord('CUSTOMER', 'LNAME', Fields.)
  37. if status = 1 then
  38. do
  39.         do index = 1 to Fields.0
  40.                 say Fields.index
  41.         end
  42. end
  43.  
  44.  
  45. status = RxViperCloseDatabase('CUSTOMER')
  46. if status = 0 then
  47. Do
  48.         say 'Failed to close CUSTOMER database!'
  49.         exit
  50. End
  51. else
  52.         say 'Successfully closed CUSTOMER database!'
  53.  
  54.