home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / informix / 1629 < prev    next >
Encoding:
Text File  |  1992-07-29  |  3.9 KB  |  123 lines

  1. Newsgroups: comp.databases.informix
  2. Path: sparky!uunet!ftpbox!mothost!techmpc!daves
  3. From: daves@techmpc.csg.gss.mot.com (Dave Schmitt)
  4. Subject: Re: Way to get list of all databases?
  5. Organization: Motorola Cellular Subscriber Group MIS
  6. Date: Wed, 29 Jul 1992 19:32:15 GMT
  7. Message-ID: <1992Jul29.193215.16577@techmpc.csg.gss.mot.com>
  8. References: <1992Jul28.155440.29855@cbis.ece.drexel.edu>
  9. Lines: 112
  10.  
  11.  
  12. In article <1992Jul28.155440.29855@cbis.ece.drexel.edu> you write:
  13. >
  14. >  Does someone know of a way (easy or not, but needs to be executeable
  15. >from command line, not interactive) to return a list of all the available
  16. >databases?  Someone pointed out that we should probably be running
  17. >'update statistics' on them each not, so tha tthe cost based optimizer
  18. >will have accurate information.
  19.  
  20. Based on the sqgetdbs() call mentioned in another article, I put together
  21. the following stand-alone C program that lists available databases.
  22. It works with Informix 4.0, both SE and OnLine, and also with Informix*Net
  23. (and I assume Informix*Star), so make sure your DBPATH doesn't include
  24. remote hosts if you only want local databases.
  25.  
  26. Unfortunately, you need RDS or ESQL in order to compile because of
  27. library routines required by "libsql.a".  See the Makefile for details
  28. on choosing the library for compilation.
  29.  
  30. This is unsupported, undocumented, and comes with no guarantees.
  31.  
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of shell archive."
  39. # Contents:  Makefile dbnames.c
  40. # Wrapped by daves@techmpc on Wed Jul 29 14:23:41 1992
  41. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  42. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'Makefile'\"
  44. else
  45. echo shar: Extracting \"'Makefile'\" \(426 characters\)
  46. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  47. X#
  48. X# The following symbols are not available in the sql library, nor in the
  49. X# compiled C 4gl development package, either:
  50. X#
  51. X#    frmcmpr
  52. X#    compact
  53. X#
  54. X# You need either the RDS or ESQL package in order to compile.
  55. X#
  56. X# RDS use: SPECIAL=rds
  57. X#
  58. X# ESQL-C use: SPECIAL=sace or SPECIAL=sperf (either is o.k.)
  59. X#
  60. X
  61. XSPECIAL=rds
  62. X
  63. XLIBS = -L$(INFORMIXDIR)/lib -lsql -l$(SPECIAL)
  64. X
  65. Xdbnames : dbnames.o
  66. X    $(CC) $(CFLAGS) -o dbnames dbnames.o $(LIBS)
  67. END_OF_FILE
  68. if test 426 -ne `wc -c <'Makefile'`; then
  69.     echo shar: \"'Makefile'\" unpacked with wrong size!
  70. fi
  71. # end of 'Makefile'
  72. fi
  73. if test -f 'dbnames.c' -a "${1}" != "-c" ; then 
  74.   echo shar: Will not clobber existing file \"'dbnames.c'\"
  75. else
  76. echo shar: Extracting \"'dbnames.c'\" \(683 characters\)
  77. sed "s/^X//" >'dbnames.c' <<'END_OF_FILE'
  78. X#include <stdio.h>
  79. X
  80. X/* This is a short C program to print a list of available
  81. X   Informix databases to stdout. */
  82. X
  83. X#define    MAXDBNAMES    256    /* you can change this */
  84. X#define    AREA        256
  85. Xextern int sqgetdbs();
  86. X
  87. Xint main(argc, argv)
  88. Xint argc;
  89. Xchar **argv;
  90. X{
  91. X  int ndb, sqlcode, i;
  92. X  char *fnames[MAXDBNAMES];
  93. X  char area[AREA];
  94. X
  95. X  sqlcode = sqgetdbs(&ndb, fnames, MAXDBNAMES, area, AREA);
  96. X  if (sqlcode) {
  97. X    (void) fprintf(
  98. X      stderr, "%s: error code %d from sqgetdbs()\n", *argv, sqlcode);
  99. X    exit(2);
  100. X  }
  101. X  for(i=0; i < ndb; i++) {
  102. X    if (printf("%s\n", fnames[i])) {
  103. X      (void) fprintf(stderr, "%s: Error printing to stdout.", *argv);
  104. X      exit(2);
  105. X    }
  106. X  }
  107. X  return(0);
  108. X}
  109. END_OF_FILE
  110. if test 683 -ne `wc -c <'dbnames.c'`; then
  111.     echo shar: \"'dbnames.c'\" unpacked with wrong size!
  112. fi
  113. # end of 'dbnames.c'
  114. fi
  115. echo shar: End of shell archive.
  116. exit 0
  117. -- 
  118. David Schmitt, Database/Systems Administrator    Voice: (708)632-5562
  119. Cellular Subscriber Group MIS            FAX:   (708)632-4421
  120. Motorola, Inc., Room S356            Email: daves@csg.gss.mot.com
  121. 1475 W. Shure Dr., Arlington Hts, IL 60004    
  122.