home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / database / informix / 1920 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.0 KB  |  86 lines

  1. Path: sparky!uunet!gatech!emory!hermes1.sps.mot.com
  2. From: baskett@hermes1.sps.mot.com (Bob Baskett)
  3. Newsgroups: comp.databases.informix
  4. Subject: db names
  5. Message-ID: <9525@emory.mathcs.emory.edu>
  6. Date: 13 Sep 92 18:08:07 GMT
  7. Sender: walt@mathcs.emory.edu
  8. Reply-To: baskett@hermes1.sps.mot.com (Bob Baskett)
  9. Lines: 74
  10. X-Informix-List-ID: <list.1442>
  11.  
  12.  
  13. here is a program that should dump the database names for an online instance:
  14. -----------------------------------------------------------------------------
  15.  
  16. /*
  17. ===============================================================================
  18. program : dbnames.ec
  19. compile : esql -o dbnames dbnames.ec
  20. short description : 
  21.           list all available database names in an online system
  22. long description :
  23.           program created (by Informix) for a customer to get all the
  24.           database names, makes unsupported library calls, use at your own risk
  25. notes   : modified printf so that it pipe delimits the output so it
  26.           can be loaded into a db table
  27. ===============================================================================
  28. */
  29.  
  30. #include <sqlhdr.h>
  31. #include <sqlca.h>
  32. #include <stdio.h>
  33.  
  34. #define MAXDBS 100
  35. #define FASIZ  MAXDBS * 19
  36.  
  37. main()
  38. {
  39.   int fcnt;
  40.   char *frmname[MAXDBS+1];
  41.   char farea[FASIZ];
  42.   int i;
  43.  
  44.   sqgetdbs(&fcnt,frmname,MAXDBS,farea,FASIZ);
  45.  
  46.   for ( i=0; i<fcnt; ++i) {
  47.     printf("%s~\n",frmname[i]);
  48.   }
  49. }
  50.  
  51. compact(frm,fcnt)
  52. char **frm;
  53. int fcnt;
  54. {
  55.   register char **to, **from;
  56.   register char *last = " ";
  57.   int same;
  58.  
  59.   from = to = frm;
  60.   while (fcnt-- > 0)
  61.     {
  62.     same = stcmpr(last, *from);
  63.     last = *from;
  64.     if (same != 0)
  65.       *to++ = *from++;
  66.     else from++;
  67.     }
  68.   return (to-frm);
  69. }
  70.  
  71. frmcmpr(n1,n2)
  72. char **n1, **n2;
  73. {  
  74.   return (stcmpr(*n1,*n2));
  75. }
  76.  
  77. ------------------------------------------------------------------------------
  78.  
  79. like it says, it makes unsupported calls - use at own risk, may not work with
  80. all version or upgrades.
  81.  
  82. ------------------------------------------------------------------------------
  83. Bob Baskett
  84. Motorola, Inc
  85.  
  86.