Re: how to list all databases?
Posted in 1997
>From: sn192he@d250-hrz.uni-duisburg.de (Heckers)
>Date: 23 Jul 1997 14:11:43 GMT
>X-Informix-List-Id: <news.40754>
>
>We used to write an esql/c program to do an update statistics medium
>every night. But we have to support a lot of different platforms now
>and so I wrote a ksh-script, that does the same job. I use oncheck -pc
>to get a list of all databases and use this list to do an update
>statistics with dbaccess.
>But oncheck is very slow!
>Who knows a faster method?
Look in the 7.20 and later ESQL/C manuals (I haven't checked earlier
versions) for the sqgetdbs() function. It is finally documented. The
function has been present since time immemorial, and there is code in
the IIUG archives (http://www.iiug.org) to print the names of the
databases.
It is even relatively fast:
$ time dbnames
apt@anubis_47
logged@anubis_47
mode_ansi@anubis_47
stores@anubis_47
svs@anubis_47
sysmaster@anubis_47
sysutils@anubis_47
unlogged@anubis_47
real 0m0.85s
user 0m0.18s
sys 0m0.13s
$
You can either compile it per (major) version of Informix in use (for 5,
6, 7, ...) and place it in appropriate $INFORMIXDIR/bin directories, or
you can try using a single version for all; I'd build with 7.2x and
simply set INFORMIXSERVER appropriately. This might require more care
and attention, so 'one-per-version' is probably easier to manage.
Yours,
Jonathan Leffler (johnl@informix.com) #include <witticism.h>