.
contact contact


dbimport database restructuring

 
.
  If the dbimport -r option is specified, dbimport will operate in restructure mode. In this mode, data sets and items are identified by name rather than number or position in record.

In restructure mode, dbimport is able to import the database content automatically. Unless set names or item names were changed a restructure specification file is not needed (option -r-).
If data set or item names were changed or new data sets need to be initialized then a restructure specification is specified with the -r option.

dbimport restructure file syntax

IMPORT SET data set [ = data set]
{
   item spec = item spec;
   item spec = :NULL;
   item spec = :CONST constant;
   ...
}
Where data set specifies a data set name or number and item spec specifies an item name or number. If an item is defined with a subitem count (array) the items elements may be handled individually.

ITEM
This specifies all elements

ITEM [1]
Specifies the first element

ITEM [1-3]
This will specify elements 1 to 3

:NULL
Initialize item with default value. This is zero for any numeric item type or spaces for strings. This is the default for new items.

:CONST
Initialize item with a constant value. Only integer or string constants may be specified here. Floating point values or numeric values exceeding integer limits may be specified as string (eg. "3.1415").
A hash sign (#) indicates a comment. Any characters past '#' (unless in a quoted string) are ignored until the end-of-line.

For the database to be loaded, data set/item names are taken from the schema. For the export file(s) the data set/item names are saved by the dbexport utility if run with the -r option. If no data set/item names are saved in the export file(s) (dbexport not run with -r option) you have to specify each item that has a different position in the export set.

Syntax Specification

NUMBER = positive integer constant

import_spec:
  /* empty */
  | set_spec import_spec

set_spec:
   IMPORT SET to_set from_set
    set_spec_item_part

set_spec_item_part:
  /* empty */
  | "{" item_spec_list "}"

to_set:				/* target set */
  set_name | set_number

from_set:			/* set in import file */
  /* empty */ 
  | "=" set_name 
  | "=" set_number

item_spec_list:
  /* empty */
  | item_spec item_spec_list

item_spec:			/* item conversion spec */
  to_spec "=" from_spec ";"

to_spec:			/* target item (range) */
  to_item range_spec

to_item:
  item_name | item_number

from_spec:
  NUMBER			/* field number in exported record */
  | item_name 			/* or exported field name (range) */
  | ":NULL"			/* NULL (default) value */
  | ":CONST" NUMBER		/* integer constant */
  | ":CONST" quoted_string	/* string constant */


range_spec:			/* array element range */
  /*  empty */
  | "[" NUMBER "]"
  | "[" NUMBER "-" NUMBER "]"

Examples

Example 1:
# Import set CUSTOMER from ACCOUNTS
IMPORT SET CUSTOMER = ACCOUNTS

# Fill PRODUCT from ORDER
IMPORT SET PRODUCT = ORDER
{
   PRODUCT-NO = ORDER-NO;
   PROD-DESC  = :CONST "* Unknown *";
   # all other default
}
Example 2:
New database ...           Old database ...

ITEMS:                     ITEMS:

   ORDER-NO,	  X8;         ORDER-NO,      X8;
   PRODUCT-NO,    X6;         PRODUCT-NO,    X6;
   QUANTITY,	  I;          QUANTITY,      I;
   SHIPMENT-DATE, X4;         SHIPMENT-DATE, X4;
   QTY-AVAIL,	  I;          ARRAY,	    3I;
   ARRAY,	  4I;

   SETS:                   SETS:

N: ORDER-DETAIL D(/0);     N: PRODUCTION D (/0);
E: ORDER-NO,		   E: ORDER-NO,
   PRODUCT-NO,  	      PRODUCT-NO,
   QUANTITY,		      QUANTITY,
   SHIPMENT-DATE,	      SHIPMENT-DATE,
   QTY-AVAIL,		      ARRAY;
   ARRAY;
You want to load your new data set ORDER-DETAIL from your old data set PRODUCTION. All data items should be taken from the the old data set with the following exceptions:
  • The new QTY-AVAIL should be filled from the old QUANTITY item.
  • The new QUANTITY item should be filled with zero.
  • The new SHIPMENT-DATE should be set to a constant value.
  • The new ARRAY item should be shifted.
The import specification file should contain...
IMPORT SET ORDER-DETAIL = PRODUCTION
{
   QTY-AVAIL = QUANTITY;
   QUANTITY  = :NULL;
   SHIPMENT-DATE = :CONST "0000";
   ARRAY[1-2] = ARRAY[1-2];
   ARRAY[4] = ARRAY[3];
   ARRAY[3] = :CONST 1;
}

See also

dbimport utility


 
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision: 2014-08-14  
  Copyright © 1995-2021 Marxmeier Software AG