Re: I: Upgrading a Informix 4.10 database 1
Posted in 1996
Hello Magnus,
we have the same problem with many installations with
different databases. So I wrote a little INFORMIX-4GL
program to print the schema of a database: dbinfo.4gl.
So I do it with our database and with the database I
want to compare. Now you can use the UNIX 'diff' to compare
this two files.
It works very nice. Sorry, the language is german.
MAGNUS wrote:
>
> Dear all,
>
> My customer has an INFORMIX 4.10 SE database on SCO UNIX. We have now made
> a lot of additions and changes to their existing database tables.
>
> I can create a dbschema for the old and the new layouts. My question is if
> there is any tool which can compare these two schemas and create an update
> script. Un intelligent 'diff' if you like.
>
> A different matter altogheter are the changes made to the data.
>
> Regards,
> Magnus Lundgren
> Digital Equipment
> Bangkok
I hope I help you
Uwe
{----------------------------------------------------------------------------}
{ MESSERKNECHT : 4GL-Programm : Droste }
{ DATENSYSTEME : Informaton zur Datenbankstruktur : ORG II }
{ GMBH : : 06.01.93 }
{----------------------------------------------------------------------------}
{ PROJEKT : Seesped }
{ TEILPROJEKT : Datenbankverwaltung }
{ MODULE : }
{ DATENBANK : export.DBS }
{ HAUPTPROGRAM : dbinfo.4gl }
{ TYP : MAIN (MAIN, GLOBAL, STANDARD, MODULE) }
{----------------------------------------------------------------------------}
{ VERWENDETE MASKEN }
{ DATEINAME NAME BESCHREIBUNG }
{----------------------------------------------------------------------------}
{ TABELLEN SEL/INS/UPD/DEL }
{ systables x - - - }
{ syscolumns x - - - }
{----------------------------------------------------------------------------}
{ AENDERUNGEN }
{ NR. DATUM BESCHREIBUNG AUTOR }
{ 1 04.01.93 4GL-Programm wurde angelegt. Droste}
{----------------------------------------------------------------------------}
{ BESCHREIBUNG : }
{----------------------------------------------------------------------------}
DATABASE export
define v_diff integer, # 1 => nur Ausgaben fuer diff
# 0 => alle Angaben einer Tabelle
dbname char (80)
MAIN
define pr_systables record
tabname like systables.tabname,
tabid like systables.tabid,
rowsize like systables.rowsize,
ncols like systables.ncols,
nindexes like systables.nindexes
end record,
cmd_str char (512),
antw char (1),
i integer
if num_args () != 1 then
display "Falsche Anzahl von Paramentern"
exit program
end if
{ case
when upshift (arg_val (2)) = "D"
let v_diff = TRUE
when upshift (arg_val (2)) = "A"
let v_diff =FALSE
otherwise
display "Falsche Parameter. Nur 'A' fuer alle Angaben bzw. 'D' fuer diff erlaubt !"
exit program
end case}
let v_diff = TRUE
let dbname = arg_val (1)
close database
display "Datenbank ", dbname clipped, " 'ffnen"
let cmd_str = "database '", dbname clipped, "'"
prepare ex1 from cmd_str
whenever error continue
execute ex1
whenever error stop
case sqlca.sqlcode
when FALSE
when -329
display "Datenbank nicht gefunden !"
exit program
otherwise
display "Fehler: ", sqlca.sqlcode, " beim 'ffnen der Datenbank ", dbname
exit program
end case
declare c_tables cursor for
select tabname, tabid, rowsize, ncols, nindexes from systables
where tabtype matches "[TV]" and
tabname not matches "sys*"
order by tabname
let i = 0
start report r_kurzinfo to "dbinfo.tx1"
start report r_langinfo to "dbinfo.tx2"
foreach c_tables into pr_systables.*
display "Tabellenstruktur auslesen f'r: ", pr_systables.tabname
output to report r_kurzinfo (pr_systables.*)
output to report r_langinfo (pr_systables.*)
end foreach
let cmd_str = "rm -f dbinfo.txt"
call c_run (cmd_str)
finish report r_kurzinfo
call c_formfeed ("dbinfo.tx1", "dbinfo.txt")
finish report r_langinfo
call c_formfeed ("dbinfo.tx2", "dbinfo.txt")
display "Fertig"
END MAIN
REPORT r_kurzinfo (fr_systables)
define fr_systables record
tabname like systables.tabname,
tabid like systables.tabid,
rowsize like systables.rowsize,
ncols like systables.ncols,
nindexes like systables.nindexes
end record,
i integer
output
page length 64
left margin 0
top margin 0
bottom margin 0
order external by fr_systables.tabname
format
page header
print ascii 27, "(s12H"
skip 1 line
print ascii 27, "\\"g1B", " ", # Mit Fettdruck !
column 30, "Tabellenstruktur der Datenbank: ",
ascii 27, "\\"g1B",
"export",
ascii 27, "\\"g0B";
if v_diff = FALSE then
print column 85, today using "Datum: dd.mm.yyyy"
else
print ""
end if
print column 75, pageno using "Seite: ####"
skip 1 line
print column 10, "Tabelle",
column 30, "Satzl'nge",
column 50, "Anzahl Spalten",
column 70, "Anzahl Indizes"
for i = 10 to 83
print column i, "=";
end for
print ""
on every row
print column 10, fr_systables.tabname,
column 31, fr_systables.rowsize using "##,##&",
column 53, fr_systables.ncols using "#,##&",
column 73, fr_systables.nindexes using "#,##&"
{on last row
if v_diff = FALSE then
need 4 lines
skip 2 lines