DB2 ist ein Produkt der
IBM Corporation. Bitte Copyright- und Trademark-Hinweise beachten!
# run: db2 get dbm cfg | awk -f upd_cfg.awk > upd_dbm.sql
# run: db2 get db cfg for xx | awk -f upd_cfg.awk > upd_db_xx.sql
BEGIN{once = 0 ; set_NEWLOGPATH=0 }
/Database Manager Configuration/ && (once == 0){
print "UPDATE DBM CFG USING";
once = 1;
FS=" = ";
}
/Database Configuration for Database/ && (once == 0){
print "UPDATE DB CFG FOR " $NF " USING";
once = 1;
FS=" = ";
}
{# Print the original line as a comment
print "--" $0;
}
# Look for configurable parameters in parenthases
/\([A-Z]+[A-Z_0-9]*\)/{
match( $1, /\([A-Z]+[A-Z_0-9]*\)/ );
# pull out parameter name and current value
parm = substr( $1, RSTART+1, RLENGTH-2);
val = $2;
# If the value is blank, set to empty string
if (val ~ /^ *$/) {
# Exception made for NEWLOGPATH, since empty string forces
# value of a default path
if (parm == "NEWLOGPATH") {
set_NEWLOGPATH=1;
next; # Skip the rest, don't print anything, see below
} else {
val = "''";
}
} else {
# Remove part of value btwn paren's. Force recalc (-1) when:
# 1) value contains "(caluculated)"; 2) value starts with "MAX";
# 3) entire value was between paren's
gsub( /\(.*\)/, "", $2);
if ( (val ~ /\(calculated\)/) || (val ~ /^MAX/) ||
($2 ~ /^ *$/) ) {
val = "-1";
} else {
val = $2;
}
}
# Print the uncommented line
printf "%57.57s %s\n", parm, val;
}
# Exception for NEWLOGPATH: Set it to the current log path
/Path to log files/ && set_NEWLOGPATH{
printf "%57.57s %s\n", "NEWLOGPATH", $2;
}
END{print ";" }
© Gernot Ruban