sunnyleung
New Member
Hello there,
I would like to get the tables contents automatically through the following two programs. Program one(exportdata.p) is used to get table lists from the silverdb.list text file and then call program two(exportdata2.p) to generate all records through the "field-name", but I don't know how to do it because it can't allow to get the value of field inside the "_file" block, please pay attention to " PUT value(_field-name)" on program two. Thanks.
silverdb.list
-----------
pt_mstr
ps_mstr
wo_mstr
wod_det
..
..
Program one:exportdata.p
define variable filepath as char format "x(40)"
initial "/silverdb.list".
define variable table_name as char format "x(30)".
define variable filename as char format "x(15)" initial "/exportdata2.p".
INPUT from value(filepath) NO-ECHO.
main-loop:
repeat:
set table_name with no-box no-attr-space.
RUN value(filename) table_name.
end.
INPUT CLOSE.
Program two:exportdata2.p
output to {1}.sql.
FOR EACH {1} no-lock:
PUT "INSERT INTO".
PUT "{1}".
PUT " VALUES(".
FOR EACH _file no-lock where _file-name = "{1}", each _field of _file:
PUT value(_field-name).
END.
END.
OUTPUT CLOSE.
I would like to get the tables contents automatically through the following two programs. Program one(exportdata.p) is used to get table lists from the silverdb.list text file and then call program two(exportdata2.p) to generate all records through the "field-name", but I don't know how to do it because it can't allow to get the value of field inside the "_file" block, please pay attention to " PUT value(_field-name)" on program two. Thanks.
silverdb.list
-----------
pt_mstr
ps_mstr
wo_mstr
wod_det
..
..
Program one:exportdata.p
define variable filepath as char format "x(40)"
initial "/silverdb.list".
define variable table_name as char format "x(30)".
define variable filename as char format "x(15)" initial "/exportdata2.p".
INPUT from value(filepath) NO-ECHO.
main-loop:
repeat:
set table_name with no-box no-attr-space.
RUN value(filename) table_name.
end.
INPUT CLOSE.
Program two:exportdata2.p
output to {1}.sql.
FOR EACH {1} no-lock:
PUT "INSERT INTO".
PUT "{1}".
PUT " VALUES(".
FOR EACH _file no-lock where _file-name = "{1}", each _field of _file:
PUT value(_field-name).
END.
END.
OUTPUT CLOSE.