HPlogo IMAGE/SQL Administration Guide: HP 3000 MPE/iX Computer Systems > Chapter 4 IMAGE/SQL Utility Commands

UPDATE TYPE

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Updates data type mapping information.

Syntax

U[PDATE] TYPE { SourceType IN { * MappedTable } IN MappedTable.Col } [TO NewMappedType]

Parameters

SourceType

is a TurboIMAGE/XL data item type whose data type mapping information you want to update. Use either this parameter or the MappedTable.Col parameter.

* (asterisk)

indicates that you want to update data type mapping for a source data type in all mapped tables where it occurs. Use either this option or specify the individual table to be updated.

MappedTable

is the name of a mapped table containing a data type whose mapping you want to update. Use either this parameter or the asterisk (*) option.

MappedTable.Col

is the name of a column in a specific mapped table whose data type mapping you want to update. Use either this parameter or the SourceType parameter.

NewMappedType

is the new data type you want to assign. If this parameter is omitted, default IMAGE/SQL utility data type mapping is used. (See Table 2-6 “IMAGE/SQL Data Type Mapping Defaults and Alternatives” for allowed data type mappings.)

Prerequisites

  • SET SQLDBE issued.

  • SET TURBODB issued.

  • DBA authority.

  • Database attached.

Description

Use the UPDATE TYPE command to update the data type mapping information in one of the following situations:

  • For all occurrences of a specified source data type in the database.

  • For all occurrences of the source data type in a specified mapped table.

  • For one occurrence of the source data type in a particular column of a specified table.

To return the TurboIMAGE/XL data type or mapped column to default IMAGE/SQL utility data type mapping values, omit the TO NewMappedType parameter.

Update data type mapping before IMAGE/SQL users access the database because when a mapped column is updated, all user-created views containing these mapped columns are dropped. When a mapped column type is updated, the definition for the mapped table to which this mapped column belongs is removed from the system catalog of the DBEnvironment. This also results in the removal of definitions for hash, B-Tree, and third-party indices for the table. The new definition for the mapped table is reentered in the system catalog of the DBEnvironment. In addition, new definitions for indices are also reentered in the system catalog of the DBEnvironment.

UPDATE TYPE stores the new data type mapping information in the ATCINFO file (DBEnvironmentNameCR). The DISPLAY MAP command reflects the updated type information. Data type updates are restricted to those data types that have alternative data type mapping. The UPDATE TYPE command only affects the DBEnvironment named in the SET SQLDBE statement.

Table 2-2 “Checklist for Maintaining the IMAGE/SQL Environment” in Chapter 2 summarizes IMAGE/SQL data type mapping defaults and alternatives.

NOTE: Updating a TurboIMAGE field X16 or K8 to an SQL DATE type means that data entered through SQL is not readable via pure TurboIMAGE/XL applications. You need to use an API routine as described in Appendix F, "Date/Time API."

Example

The first example shows how to convert fields in a data base to a decimal value with a varying number of decimal places. You can map type J2 to decimal type (10,n) where 0≤n<10.

  • Use this command to remap all J2 fields in a data base to 0 decimal places:

       >>UPDATE TYPE J2 IN * TO DECIMAL(10,0)
    
  • Use this command to remap all J2 fields in a data set to 2 decimal places:

       >>UPDATE TYPE J2 IN tablename  TO DECIMAL(10,2)
    
  • Use this command to remap one particular field in a data set to 1 decimal place:

       >>UPDATE TYPE IN table.column  TO DECIMAL(10,1)
    

In this second example, the UPDATE TYPE command is used to specify the alternative mapping ALLBASE/SQL CHAR(4). This is a byte-by-byte transfer (R2 is 4 bytes long). No data conversion is performed.

   >>UPDATE TYPE R2 IN CUSTOMER TO CHAR(4)

   Updated information in table CUSTOMER.

   >>

After the data type update, the DISPLAY MAP command reflects the change:

 >>DISPLAY MAP CUSTOMER



 TurboIMAGE/XL DB : SALES.SERED.ATC

 DBEnvironment    : PARTSDBE.SERED.ATC

 Owner Name       : SALES



 MAPPED(SOURCE)   SOURCE             MAPPED       SOURCE     MAPPED

    TABLE         FIELD              COLUMN        TYPE       TYPE    NOTES

 ------------ ---------------- ------------------ ------- ----------- -----





 CUSTOMER (CUSTOMER)

              CUSTOMER#        CUSTOMER#          J2      INTEGER

              LAST-NAME        LAST_NAME          X16     CHAR(16)

              FIRST-NAME       FIRST_NAME         X10     CHAR(10)

              INITIAL          INITIAL            U2      CHAR(2)

              STREET           STREET             X26     CHAR(26)

              CITY             CITY               X12     CHAR(12)

              STATE            STATE              X2      CHAR(2)

              ZIP              ZIP                X6      CHAR(6)

              CREDIT-RATING    CREDIT_RATING      R2      CHAR(4)     IU



 NOTES:

   I: Imprecise(float)/Incompatible(others) mapping between source and

      mapped data types

   U: Source field has been updated

 >>


In the above example, the NOTES column indicates that the data type mapping for CREDIT_RATING, the only mapped column whose source data type is R2, has been updated. The I indicates that the updated data type mapping is incompatible with the original data type.

Feedback to webmaster