Kbase 11040: Copy records from one database to another using metaschema
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
Copy records from one database to another using metaschema
INTRODUCTION:
=============
This Technical Support Knowledgebase Entry demonstrates how to write
a program that writes a program using the metaschema files. The
example illustrates populating one database with the data from another
matching database.
WHY YOU NEED TO KNOW THIS:
===========================
You may need to ASSIGN data values from one database file to another
where the schema designs are the same, for example, to create test
data for your application.
PROCEDURAL APPROACH:
====================
Use the features of the PROGRESS metaschema to write a program that
displays the necessary strings of characters to produce a 4GL program
to accomplish the task. This example uses the demo63 and demo data-
bases. The demo63 database contains data records as well as data
structure definitions; the demo database contains only definitions.
/********************************************************************************************************************************************************
** Program: makeprog.p
**
*****************************************************************************
\***************************************************************************/
OUTPUT TO populate.p.
DEF VAR i AS INTEGER.
FOR EACH demo63._file WHERE _file-number > 0:
FOR EACH _field WHERE _file-recid = RECID(_file) NO-LOCK BREAK BY
_file-recid:
IF FIRST-OF(_file-recid) THEN
DO:
DISPLAY "FOR EACH demo63." + _file-name + ":" FORMAT "x(55)".
DISPLAY " CREATE demo." + _file-name + "." FORMAT "x(55)" .
END.
IF _extent > 1 THEN
DO:
REPEAT i = 1 TO _extent:
DISPLAY "ASSIGN demo." + _file-name + "." + _field-name + "[" +
+ STRING(i) + "]"
+ " = demo63." + _file-name + "." + _field-name + "[" +
STRING(i) + "]"
+ "." FORMAT "x(78)" WITH FRAME x.
END. /* repeat */
END. /* IF _Extent > 1 */
ELSE /* not an arrayed field */
DISPLAY " ASSIGN demo." + _file-name + "." + _field-name
+ " = demo63." + _file-name + "." + _field-name
+ "." FORMAT "x(78)".
IF LAST-OF(_file-recid) THEN
DO:
DISPLAY "END.".
END.
END.
END.
OUTPUT CLOSE.
OUTPUT TO TERMINAL.
DISPLAY "running data conversion".
RUN populate.p.
REFERENCES TO WRITTEN DOCUMENTATION:
===================================
See Section 15.4.6 PROGRESS Schema Files in the Version 6 Programming
Handbook, or Appendix B of the Version 7 SQL Guide and Reference.
See Chapter 2 of the PROGRESS System Administration Student Guide.
Progress Software Technical Support Note # 11040