SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-111
Examples—CONVERT
string
--WARNING The default value is truncated.
G VARCHAR(8) NOT NULL , -- WARNING - PIC N
PRIMARY KEY C
)
If the DDL default string is longer than eight characters, CONVERT truncates the
default string to eight bytes long.
This example illustrates more features of the CONVERT command. The DDL
record definition follows:
RECORD SCHEDULE.
FILE IS "$VOL3.DDL.SCHEDULE" KEY-SEQUENCED.
02 EMP-SCHEDULE.
03 EMPNUM PIC 9(5).
03 EMPNUM-KEY REDEFINES EMPNUM.
05 DEP-KEY PIC X(2).
05 EMP-KEY PIC X(3).
03 DAY-SCHED OCCURS 5 TIMES.
04 DAYNUM PIC X(2).
04 SHIFTS OCCURS 2 TIMES.
05 START-HOUR PIC 9(2).
05 END-HOUR PIC 9(2).
KEY IS EMPNUM DUPLICATES NOT ALLOWED.
END
This command produces an EDIT file named SCHDCONV, which contains
commands that convert the Enscribe file to a table and includes comments in the
CREATE TABLE command:
>>CONVERT RECORD SCHEDULE TO TABLE $VOL1.PERSNL.SCHEDULE
+>REDEFINE(EMP-SCHEDULE.EMPNUM AS EMP-SCHEDULE.EMPNUM-KEY)
+>COMMENTS SOURCE SCHDCONV CLEAR;
The EMPNUM field is converted to two columns named DEP_KEY and EMP_KEY
based on the elementary fields of the EMPNUM-KEY redefinition. The column
definitions in the CREATE TABLE command are:
DEP_KEY PIC X(2),
EMP_KEY PIC X(3),
The LOAD command in the SCHDCONV file contains the
REDEFINE (EMP-SCHEDULE.EMPNUM AS EMP-SCHEDULE.EMPNUM-KEY)
option. The CREATE TABLE command follows:
CREATE TABLE $VOL1.PERSNL.SCHEDULE
(
-- 02 EMP-SCHEDULE
-- 03 EMPNUM-KEY
-- 04 DEP-KEY
DEP_KEY PIC X(2) NOT NULL,
-- 04 EMP-KEY
EMP_KEY PIC X(3) NOT NULL,