Re: Engine Database List
Posted in 1996
Romulo Albuquerque wrote:
>
> Hi All,
>
> I'm using Informix Online 5.x. Anyone knows how can I get a list of
> databases from a .4GL program ?
>
> TIA,
>
> Romulo Albuquerque
>
Romulo,
here is a possible solution that I composed from a script solution from Joe
Lumbleys excellent book "Informix Database Administrator's Survival Guide"
and a sample 4GL routine to read ascii files provided from Kerry Sainsbury.
HTH
Tolis
+---------------------------------------------------------------------+
| V+K Relational Solutions email: tvarnas@compulink.gr |
| Deligiorgi 26 tvarnas@orbit.de |
| 546 42 Thessaloniki Voice: (30) 31 820270 |
| Greece Fax: (30) 31 865463 |
+---------------------------------------------------------------------+
------------------------ cut here-------------------------------------
database [input_your_database_here]
define m_temp_exists smallint
main
define l_dbnames char(80)
let m_temp_exists = false
if find_dbnames() then
declare c_dbnames cursor for
select * from t_dbnames
foreach c_dbnames into l_dbnames
display l_dbnames
end foreach
end if
end main
function find_dbnames()
define l_unix_cmd char(200),
l_tempfile char(30),
l_ok smallint,
l_dbnames char(80)
whenever any error continue
if not m_temp_exists then
create temp table t_dbnames
(dbname char(80)) with no log
let m_temp_exists = true
else
delete from t_dbnames
end if
let l_tempfile = "/tmp/",TIME,".tmp"
let l_unix_cmd = "tbcheck -pe | grep systables | grep -v WARNING | tr
\\":\\" \\" \\" | awk '{print $1}' | sort -u > ",l_tempfile
run l_unix_cmd
load from l_tempfile insert into t_dbnames
if status then
let l_ok = false
else
let l_ok = true
end if
let l_unix_cmd = "rm -f ",l_tempfile
run l_unix_cmd without waiting
if l_ok then
return true
else
return false
end if
whenever any error stop
end function