Re: SQL to search for column name
Posted in 2006
bozon — — source: Usenet: comp.databases.informix
#!/usr/bin/ksh
#trap "cleanup ; exit" 0 1 2 15
function usage {
printf "\\n\\n Usage: %s <colname> \\n\\n" "`basename $0`" 1>&2
exit 1
}
#function cleanup {
#}
if [ $# -ne 1 ] ; then
usage
fi
asdb=`dbaccess sysmaster <<EOF 2>/dev/null | grep -v ^$
set isolation to dirty read; output to pipe cat without headings
select name from sysdatabases ;EOF
`
for db in $asdb ; do
( dbaccess $db <<EOF 2>/dev/null | grep -v ^$
output to pipe cat without headings
select substr("$db",1,20), substr(tabname,1,20),
substr(colname, 1, 20)
from systables, syscolumns
where systables.tabid = syscolumns.tabid and
colname like "%$1%"
EOF
) &
done | sort