Re: Online 4.10 Dbexport/Dbimport
Posted in 1992
warren,
we have the same problem with dbexport/dbimport. i have a 4gl program
that ive run a couple of times and it appears to work. its not elegant
but it works
--------------------------------------------------------------------------
#
# purpose : this program will fix dbexport by adding dbspace, extents,
# and lock mode.
#
# notes : this program is not guarenteed to work 100% as it was written
# while on the phone
database stores
globals
define quote char(1)
define squote char(1)
define eoln char(2)
define db_name like systables.tabname
define tab_name like systables.tabname
define tab_owner like systables.owner
define p_systables record like systables.*
define sql1 char(1024)
end globals
main
define exec_cmd char(1024)
define p_line char(500)
define l integer
define string1 char(100)
let quote = "\\""
let squote = "\\'"
let eoln = "\\\\n"
whenever error continue
drop table dbexport_tp1
whenever error stop
create table dbexport_tp1 (line char(500))
let exec_cmd = "cat *.exp/*.sql | ",
"awk ",squote,"{printf (",quote,
"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s ^",
eoln,quote,
",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20)}",
squote," > tp1.sql"
run exec_cmd
load from "tp1.sql" delimiter "^"
insert into dbexport_tp1
run "/bin/rm tp1.sql"
declare c cursor for
select *
from dbexport_tp1
foreach c into p_line
case
when (p_line[1,10] = "{ DATABASE")
let db_name = get_word(11,p_line clipped)
display p_line clipped
exit case
when (p_line[1,7] = "{ TABLE")
let tab_owner = get_word(8,p_line clipped)
let l = length(tab_owner)
let l = 8 + l + 2
let tab_name = get_word(l,p_line clipped)
display p_line clipped
exit case
when (p_line[1,4] = " );") or (p_line[1,2] = ");")
let sql1 =
"select *,hex(partnum) ",
" from ",db_name clipped,":systables where tabname = ",
quote,tab_name,quote," and owner = ",quote,tab_owner,quote
prepare getit from sql1
declare c2 cursor for getit
foreach c2 into p_systables.*,string1
let string1 = string1[3,4]
end foreach
display ")"
display "in DBSPACE_",string1 clipped
display "extent size ",p_systables.fextsize
display "next size ",p_systables.nextsize
if (p_systables.locklevel = "R")
then
display "lock mode ROW"
end if
if (p_systables.locklevel = "P")
then
display "lock mode PAGE"
end if
display ";"
exit case
otherwise
display p_line clipped
exit case
end case
end foreach
end main
function get_word (startat,pline)
define startat integer
define pline char(500)
define i integer
define l integer
define aword char(132)
define skip smallint
define ch char(1)
let l = length(pline)
let skip = true
let aword = null
for i = startat to l
let ch = pline[i]
if (pline[i] = " ")
or (pline[i] = ".")
or (pline[i] = "\\"")
then
if skip
then
continue for
else
exit for
end if
end if
let skip = false
let aword = aword clipped,pline[i]
end for
return aword
end function
--------------------------------------------------------------------------
im assuming you are on a unix box. also, this has not been corrected
in version 5.*.
--------------------------------------------------------------------------
Bob Baskett
Motorola, Inc