HPlogo Communicator 3000 MPE/iX Release 6.5 (Non-Platform Software Release C.65.00) > Chapter 6 Announcing a Post 6.5 Release Patch

IMAGE/SQL Date Mapping Enhancement

MPE documents

Complete PDF
Table of Contents
Index


CAUTION: The DATE MAPPING enhancement for IMAGE/SQL will be available in the first IMAGE/SQL patch released on MPE/iX version 6.5. This enhancement requires migration of the ATCINFO file since the ATCINFO file format has been changed to keep track of additional date related information.

The IMAGE/SQL version number for 6.5 release is B.G3.01. Since this version does not include the DATE MAPPING enhancement, no migration is needed. However, once you apply the IMAGE/SQL patch with the version number of B.G4.01, or any version following the B.G4.01 version, you need to migrate all your ATCINFO files in order to use IMAGE/SQL.

Currently, users are experiencing some problems accessing various dates in TurboIMAGE databases through IMAGE/SQL. Some typical problems are:
  • In TurboIMAGE, dates may be held in numeric or ascii fields. If no data exists in a data field, it will hold binary zeroes, and will be interpreted by SQL as zero rather than null. Any attempt to CAST this data into a DATE format will fail with an error, and the SELECT can not continue. Similarly, a failure in the validation of dates in the 3GL code will result in the same error, and the SELECT statement fails.

  • Both FA3000 and MM3000 will be handling year 2000 and beyond by incrementing the year to 'A0' for the year 2000, 'B0' for year 2010 etc. This allows their applications to be able to distinguish the year 2000 and beyond with a 'YYMMDD' format. The users of FA3000 and MM3000 need a way for IMAGE/SQL to convert the above format year to SQL DATE and vise versa. To alleviate the problems mentioned above, IMAGE/SQL has been enhanced to allow some numeric or ascii fields to be mapped to DATE columns, and the users can specify what DATE format the data is in. The date formats supported are the same as the formats supported by MPE. Following is a description of the enhanced SPLIT and UPDATE TYPE commands in the IMAGESQL program.

IMAGE/SQL SPLIT command and UPDATE TYPE command have been enhanced to allow SIGNED or UNSIGNED mapped type if the mapped type is DECIMAL. If UNSIGNED keyword is specified, then all positive values will be unsigned. The default is SIGNED. If the mapped type is DATE, and the source type is P8, Z6 or Z8, SIGNED or UNSIGNED keyword can be used to indicate whether all positive values will be SIGNED or UNSIGNED. The default is SIGNED.

IMAGE/SQL UPDATE TYPE and SPLIT commands are also enhanced to allow users to specify FORMAT=BB1 or BB2. (BB1 is for Business Basic short decimal, and BB2 for Business Basic decimal). The NewMappedType must be FLOAT. An error will be returned if a value is not in the right range.

This enhancement also has a dependency on the Business basic patch BBRDXU7 for the new Business Basic conversion routines.

SP(LIT)


Divides a large mapped column into two or more smaller columns.

Syntax


  SP[LIT] MappedTable.MappedColumn INTO NewMappedColumn:SourceType
          [FORMAT=FormatType[,lowvalue[,highvalue]]]
          [:MappedType [SIGNED  ]
                       [UNSIGNED]] [,...]

If MappedType is 'DATE', then FORMAT must be specified.

Example


  (i)    SPLIT TABLE1.COLUMN5 INTO NEWCOLUMN1:I4:CHAR(8),&
                                   NEWCOLUMN2:X20,&
                                   NEWCOLUMN3:K3:DECIMAL(15,0)
  (ii)   SPLIT TABLE2.COLUMN3 INTO NEWCOL1:I4:CHAR(8),&
                                   NEWCOL2:X20,&
                                   NEWCOL3:Z4:DECIMAL(4,0) UNSIGNED
  (iii)  SPLIT TABLE2.MYDATE INTO &
           MYDATE1:X6 FORMAT=DT35,'000000','999999':DATE, &
           MYDATE2:X6 FORMAT=DT36,'******','&&&&&&':DATE
  (iv)   SPLIT TABLE2.DDATE INTO &
           DDATE1:X6 FORMAT=DT26,'     0','    99':DATE,&
           DDATE2:X6 FORMAT=DT25,'      ','------':DATE
  (vi)   SPLIT TABLE2.MYDATE2 INTO &
           MYDATE2_1:I2 FORMAT=DT2,0,-1:DATE, &
           MYDATE2_2:I2 FORMAT=DT2,0,-1:DATE
  (vii)  SPLIT TABLE1.COLUMN5 INTO NEWCOLUMN1:I4:CHAR(8),&
                                   NEWCOUMNL2:X20,&
                                   NEWCOLUMN3:K4:FORMAT=BB2:FLOAT
  (viii) SPLIT TABLE2.MYBBDECS INTO &
           MYBBDEC_1:K2 FORMAT=BB1:FLOAT, &
           MYBBDEC_1:K4 FORMAT=BB2:FLOAT

U[PDATE] TYPE


Updates data type mapping information for a specified TurboIMAGE/iX data type or a specified Mapped Column.

Syntax


  U[PDATE] TYPE {SourceType IN {*          }
                               {MappedTable}
                 [FORMAT=FormatType[,lowvalue[,highvalue]]]}
                 {IN MappedTable.Col
                     [FORMAT=FormatType[,lowvalue[,highvalue]]]}
           [TO NewMappedType [SIGNED  ]
                             [UNSIGNED]]

If NewMappedType is 'DATE', then FORMAT must be specified.

Examples


  (i)    UPDATE TYPE I4 IN COMPOSER
  (ii)   UPDATE TYPE IN COMPOSER.BIRTHDATE TO CHAR(18)
  (iii)  UPDATE TYPE IN TABLE1.UNSIGNEDZ4 TO DECIMAL(4,0) UNSIGNED
  (iv)   UPDATE TYPE IN TABLE2.MYDATE FORMAT=DT35,'000000','999999' &
           TO DATE
  (v)    UPDATE TYPE X6 IN TABLE2 FORMAT=DT26,'     0','    99' &
           TO DATE
  (vi)   UPDATE TYPE IN TABLE2.MYDATE2 FORMAT=DT2,0,-1 TO DATE
  (vii)  UPDATE TYPE IN TABLE2.MYP8 FORMAT=DT15,0,-1 TO DATE UNSIGNED
  (viii) UPDATE TYPE IN TABLE3.MYZ6 FORMAT=DT26,'******','999999' &
           TO DATE SIGNED
  (ix)   UPDATE TYPE IN TABLE4.MYZ8 FORMAT=DT38,'--------', &
           '########' TO DATE UNSIGNED
  (x)    UPDATE TYPE K2 IN TABLE2 FORMAT=BB1 TO FLOAT
  (xi)   UPDATE TYPE IN TABLE2.MYBBDEC FORMAT=BB2 TO FLOAT(53)

Format(TI)Type StorageType #Bytes Explanation


Format (TI) Storage Type Bytes Explanation
DT1 (I4,J4,K4)longint8 MPE time-stamp
(microseconds from 1970-01-01)
DT2 (I2,J2,K2)integer 4 Upper 2 bytes: year
next byte: month of year
DT3 (I2,J2,K2)integer4 Upper 2 bytes: year
bottom 2 bytes: day of year
DT4 (I2,J2,K2)integer 4 Upper 23 bits: # years from 1900
bottom 9 bits: day of the year.
(analogous to the existing CALENDAR format.)
DT10 (I2,J2,K2)integer4 Seconds from 1970-01-01
(POSIX.1 time() format;
valid through 2038-01-18)
DT14 (I1,J1,K1)shortint2 Upper 7 bits: #years from 1900
Lower 9 bits: day of the year
(CALENDAR format; valid up to 2027-12-31)
DT15 (I2,J2,K2,P8)integer4YYMMDD date
DT16 (I2,J2,K2,P8)integer4MMDDYY date
DT17 (I2,J2,K2,P8)integer4DDMMYY date
DT18 (I2,J2,K2)integer4YYYYMMDD date
DT25 (X6,U6,K3,Z6)ASCII6YYMMDD date
DT26 (X6,U6,K3,Z6)ASCII6MMDDYY date
DT27 (X6,U6,K3,Z6)ASCII6 DDMMYY date
DT35 (X6,U6,K3) ASCII6 YYMMDD date YY:MM3000 date
DT36 (X6,U6,K3)ASCII 6MMDDYY date YY:MM3000 date
DT37 (X6,U6,K3)ASCII 6 DDMMYY date YY:MM3000 date
DT38 (X8,U8,K4,Z8)ASCII8 YYYYMMDD date
BB1 (K2)4Business Basic SHORT DECIMAL type
BB2 (K4)8Business Basic DECIMAL type

Notes


  1. MM3000 dates are represented as in the MM3000 product which uses the ASCII "A" through "Z" for decades starting with the year 2000.

  2. lowvalue will be displayed as '9900-01-01',
    highvalue will be displayed as '9999-12-31', and
    invalid value will be displayed as '9901-12-31'
    There will be no default values for lowvalue and highvalue. If lowvalue
    and/or highvalue are not provided, then the code checking for
    lowvalue/highvalue will not be exercised.

  3. For integer DT types (DT1 - DT18), the lowvalue and the highvalue must be set to integer values.

  4. For ASCII DT types (DT25 - DT38), the lowvalue and the highvalue must be set to ascii values (single quoted), 0 (for COBOL LOWVALUES), or -1 (for COBOL HIGHVALUES). Single quote character cannot be included in the lowvalue or highvalue ascii string. No padding will be done for the user. The user must provide ascii values with the correct length. For example, for DT25, the lowvalue and highvalue provided must be 6 characters long.

  5. If the TURBO data type is P8, Z6 or Z8, and it is being mapped to DATE, then [UNSIGNED/SIGNED] keyword can be used to indicate whether positive data should be SIGNED or UNSIGNED when inserting data via IMAGE/SQL. The default is SIGNED.

Examples


  1. Use IMAGESQL:

    
      UPDATE TYPE IN mytable.mydate FORMAT=DT26,'******','$$$$$$' &
        TO DATE
    
    
  2. Use ISQL

    
      INSERT INTO mytable VALUES ('9900-01-01');
        This statement will PUT '******' into the TURBO field mydate.
      INSERT INTO mytable VALUES ('9999-12-31');
        This statement will PUT '$$$$$$' into the TURBO field mydate.
      INSERT INTO date2.d2 VALUES ('9901-12-31','9901-12-31', &
                                                'bad date');
        Invalid DATE for TurboIMAGE: set 1, item 0, column 2,
        record 0.  (DBERR 13512)
        Number of rows processed is 0
      SELECT mydate FROM mytable where mydate is null;
        returns "Number of rows selected is 0"
        i.e. nothing qualifies.
      SELECT mydate FROM mytable WHERE mydate = '9900-01-01';
        returns all records with TURBO value = '******'
        (if index exist on the item, mydate, then CHAIN READ is used)
      SELECT mydate FROM mytable WHERE mydate = '9999-12-31';
        returns all records with TURBO value = '$$$$$$'
        (if index exist on the item, mydate, then CHAIN READ is used)
      SELECT mydate FROM mytable WHERE mydate = '9901-12-31';
        returns all records with TURBO value is not a valid date.
        (SERIAL READ is always used in this case)
    
    
  3. How do you migrate your ATCINFO file?


    NOTE: Before migrating your ATCINFO file of your DBE, make sure you backup your existing ATCINFO file and the matching DBE.
    
      :run imagesql.pub.sys
      > dbe yourdbe
      > migrate
    
    
  4. How do you know that your ATCINFO file needs migration?

    
      (1) :imagesql
          >> dbe mydbe
          >> base yourdb
          >> display turbodb
          Incompatible ATCINFO file version number, migration
          is needed   (ATCERR 2101).
      (2) isql=> connect to 'mydbe';
          ATCINFO file contains incompatible version number,
          migration is needed.  (DBERR 13516)
    
    
  5. How about going back to an older version?

    Possible scenario: You restored the migrated database onto a system that is running an older version of IMAGE/SQL.

    Symptoms:

    
      (1) :imagesql
          >>dbe mydbe
          >>base yourdb
          >>display turbodb
          ATCINFO procedure error (ATCERR 32421,ATCSTAT 2101,
          FSERR 0).
      (2) isql=> connect to 'mydbe';
          IMAGE/SQL internal error 141, 2101, 0, 0.  (DBERR 13554)
    
    
    What to do:

    Restore the ATCINFO file and the matching DBE from a backup before the migration.




Chapter 6 Announcing a Post 6.5 Release Patch


Chapter 7 Product List — How to Order