Re: Way to get list of databases ?
Posted in 1992
I enclose a shell archive of dbnames.ec. Compile using: esql -o dbnames dbnames.ec Probably won't wok with ESQL/C 4.10 unless you can find the file rfnmanip.o in one of the other libraries you have installed, but try it and see. Works OK with ESQL/C 4.00 and ESQL/C 5.00. This is totally unsupported, and not guaranteed on any platform whatsoever! Yours, Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h> : "@(#)shar.sh 1.8" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Wed Jul 29 22:23:04 GMT 1992 by johnl at Informix Software Ltd. # Files archived in this archive: # dbnames.ec # #-------------------- if [ -f dbnames.ec -a "$1" != "-c" ] then echo shar: dbnames.ec already exists else echo 'x - dbnames.ec (1625 characters)' sed -e 's/^X//' >dbnames.ec <<'SHAR-EOF' X/* X@(#)File: dbnames.ec X@(#)Version: 1.1 X@(#)Last changed: 91/03/14 X@(#)Purpose: Print list of visible databases X@(#)Author: John Cooke/Mark Jeske/Jonathan Leffler X*/ X X/* X********************************************************** X** This code is derived from two almost identical ** X** programs with the identifications preserved below: ** X********************************************************** X** dbnames.ec ** X** List all available database names. ** X** Mark J (Informix) 3-13-91 ** X********************************************************** X** From: johnc@obelix (John Cooke) ** X** Quite a coincidence .... I wrote THIS program: ** X** program to get the names of all visible databases ** X********************************************************** X** Compile using: ** X** esql -o dbnames dbnames.ec $INFORMIXDIR/lib/librds.a ** X********************************************************** X*/ X X#ifndef lint Xstatic char sccs[] = "@(#)dbnames.ec 1.1 91/03/14"; X#endif X X#include <stdio.h> X X#define MAXDBS 100 X#define FASIZ (MAXDBS * 19) X Xmain() X{ X int ndbs; X int sqlcode; X int i; X char *dbsname[MAXDBS + 1]; X char dbsarea[FASIZ]; X X if ((sqlcode = sqgetdbs(&ndbs, dbsname, MAXDBS, dbsarea, FASIZ)) != 0) X fprintf(stderr, "error code %d from sqgetdbs\\n", sqlcode); X else X { X for (i = 0; i < ndbs; ++i) X printf("%d %s\\n", i, dbsname[i]); X } X X return (0); X} SHAR-EOF chmod 444 dbnames.ec if [ `wc -c <dbnames.ec` -ne 1625 ] then echo shar: dbnames.ec unpacked with wrong size fi # end of overwriting check fi echo All files extracted exit 0