Using TABLE syntax, you can create extract files (tables) in the RDBMS. You can then use these tables, like any other RDBMS table, for both read-only and read-write operations. In fact, with the HOLD FORMAT SQL, DB2, SQLIDMS, SQLDBC, or SQLORA option, you can create RDBMS tables from any FOCUS-readable file. This feature facilitates data migration and leaves the original source unaffected. |
In this section: Master Files Generated by HOLD Access Files Generated by HOLD Extract File Conversion Charts Example: |
In order to create RDBMS tables and indexes, you must have an adequate level of RDBMS authority. Your site must also have enabled WRITE access and native SQL support when installing the data adapter. Contact your site DBA for more information.
To extract data and convert it to an RDBMS table, issue the HOLD command with the FORMAT SQL, DB2, SQLDBC, SQLIDMS, or SQLORA option either in the report request or after the report has printed. The data adapter generates a single-table Master and Access File, and it creates and loads one RDBMS table. If the report request uses the verbs PRINT or LIST, it also creates both a FOCLIST field with internal list values and a unique index on all BY fields and the FOCLIST field. If the request uses the verb SUM, the data adapter creates a unique index on any BY fields.
If you attempt to issue the HOLD FORMAT sqlengine command without first installing the data adapter, the following error messages are generated:
(FOC1488) SQL INTERFACE IS NOT INSTALLED
(FOC1479) ERROR CONNECTING TO SQL DATABASE
Note: Environmental Commands, describes how to control index space parameters with the DB2, IDMS/SQL, or Oracle Data Adapter SET IXSPACE command.
The RDBMS table name that results from the extract must not already exist. (See Environmental Commands, for a discussion of data adapter environmental commands that allow you to control where the table is placed.)
Within the report request, the syntax is:
ON TABLE HOLD [ AS name ] FORMAT sqlengine
At the command level, the syntax is
HOLD [ AS name ] FORMAT sqlengine
where:
Note:
Unless you give them an AS name, file descriptions are temporary and exist only for the current session. All HOLD tables are permanent and must be explicitly dropped.
To make the HOLD file descriptions permanent, specify an AS name in the HOLD command, and consider the following:
This example converts the FOCUS PROD database to a DB2 table:
sql db2 set dbspace public.space0
>
table file prod
print *
on table hold as user1.prodsql format sql
end
NUMBER OF RECORDS IN TABLE= 14 LINES= 14
HOLDING SQLDS FILE...
Even if the original Master File describes several segments, the Master File resulting from the ON TABLE HOLD extract is a single-table description; it contains the attributes described in Describing Tables to FOCUS. Following is a list of the generated keyword/value pairs: |
Example: |
If the report request contains an AS phrase to rename a field, the AS phrase name becomes the new value for FIELDNAME and the original fieldname becomes the new value for ALIAS. The AS phrase name is also included as a TITLE value.
The FOCUS PRINT and LIST commands create an additional field named FOCLIST that contains internal list values.
The following is the generated Master File from the ON TABLE HOLD AS PRODSQL command in Converting the FOCUS PROD Database to a DB2 Table:
FILE=PRODSQL ,SUFFIX=SQLDS,$
SEGNAME=SEG01 ,SEGTYPE=S0,$
FIELDNAME =FOCLIST ,FOCLIST ,I5 ,I4 ,$
FIELDNAME =PROD_CODE ,PCODE ,A3 ,A3 ,$
FIELDNAME =PROD_NAME ,ITEM ,A15 ,A15 ,$
FIELDNAME =PACKAGE ,SIZE ,A12 ,A12 ,$
FIELDNAME =UNIT_COST ,COST ,D5.2M ,D8 ,$
The following request creates a 15 character DB2 table named EMPLOYEEINFODB2 (18 is the maximum table name length for DB2):
TABLE FILE EMPLOYEE
PRINT EMP_ID CURR_SAL
BY DEPARTMENT
BY LAST_NAME
BY FIRST_NAME
ON TABLE HOLD AS USER1.EMPLOYEEINFODB2 FORMAT DB2
END
This request creates the following Master File:
$ VIRT=EMPLOYEEINFODB2
FILE=EMPLOYEEINFODB2 ,SUFFIX=SQL
SEGNAME=SEG01 ,SEGTYPE=S0
FIELDNAME ='DEPARTMENT' ,'DPT' ,A10 ,A10 ,$
FIELDNAME ='LAST_NAME' ,'LN' ,A15 ,A15 ,$
FIELDNAME ='FIRST_NAME' ,'FN' ,A10 ,A10 ,$
FIELDNAME =FOCLIST ,FOCLIST ,I5 ,I4 ,$
FIELDNAME ='EMP_ID' ,'EID' ,A9 ,A9 ,$
FIELDNAME ='CURR_SAL' ,'CSAL' ,D12.2M ,D8 ,$
This request also creates the following Access File. The AS name is also the table name:
$ VIRT=EMPLOYEEINFODB2
SEGNAME=SEG01 ,
TABLENAME=USER1.EMPLOYEEINFODB2
KEYS=04 , WRITE=YES, $
Consider what happens when the AS name is longer than the 18 characters supported for table names in DB2 on OS/390:
TABLE FILE EMPLOYEE
PRINT EMP_ID CURR_SAL
BY DEPARTMENT
BY LAST_NAME
BY FIRST_NAME
ON TABLE HOLD AS EMPLOYEEINFORMATIONDB2 FORMAT DB2
END
Running this request generates the following messages:
> NUMBER OF RECORDS IN TABLE= 12 LINES= 12
HOLDING SQL FILE...
(FOC1400) SQLCODE IS -107 (HEX: FFFFFF95)
(FOC1414) EXECUTE IMMEDIATE ERROR.
The Master and Access Files are created. However, the table cannot be created because the table name specified in the Access File is too long and, therefore, invalid. Note that you will get a more descriptive message if you issue the following command:
SQL DB2 SET ERRORTYPE DBMS
For example:
(FOC1400) SQLCODE IS -107 (HEX: FFFFFF95)
: DSNT408I SQLCODE = -107, ERROR: THE NAME EMPLOYEEINFORMATIONDB2 IS TOO
: LONG. MAXIMUM ALLOWABLE SIZE IS 18
: DSNT418I SQLSTATE = 42622 SQLSTATE RETURN CODE
: DSNT415I SQLERRP = DSNHSMUD SQL PROCEDURE DETECTING ERROR
: DSNT416I SQLERRD = 0 0 0 -1 15 0 SQL DIAGNOSTIC INFORMATION
: DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000'
: X'FFFFFFFF' X'0000000F' X'00000000' SQL DIAGNOSTIC
: INFORMATION
(FOC1414) EXECUTE IMMEDIATE ERROR.
The Access File resulting from the ON TABLE HOLD extract contains the declarations described in Describing Tables to FOCUS. For PRINT and LIST based reports, the FOCLIST field and the BY phrases determine the KEYS value and how the index is created. Following is a list of the generated keyword/value pairs: |
Example: |
Note:
For DB2, Teradata, and Oracle, if you do not specify a creator name, the ID specified by the SET OWNERID command becomes the creator. If you did not issue this command, your user ID becomes the creator by default. For IDMS, an unqualified table name will be generated.
Following is the generated Access File from the ON TABLE HOLD AS PRODSQL statement in Converting the FOCUS PROD Database to a DB2 Table:
SEGNAME=SEG01 ,
TABLENAME="USER1".PRODSQL ,
KEYS=01 , WRITE=YES, $
Three work files, FOC$HOLD MASTER, FOC$HOLD FOCTEMP, and FOCSORT, are used with an internal MODIFY procedure to create and load the output table. The FOC$HOLD Master File is a fixed-format file with a corresponding sequential data file.
The following charts show original USAGE formats, conditions, and resulting USAGE and ACTUAL formats for ON TABLE HOLD; the field length is represented by n. |
Reference: Extract File Conversion Chart for DB2 and DB2 for VM Extract File Conversion Chart for Teradata |
Non-SQL USAGE |
Conditions |
HOLD USAGE |
HOLD ACTUAL |
An |
none |
An |
An |
Dn |
none |
Dn |
D8 |
Fn |
none |
Fn |
F4 |
In |
n EQ 1 or 2 |
In |
I2 |
Pn.m |
n LE 31 |
Pn.m |
P(trunc((n+2)/2)) |
date |
Date format |
date |
DATE |
TXnn |
TEXT field |
TXnn |
TX |
HYYMDm |
Timestamp field |
HYYMDm |
HYYMDm |
HHIS |
Time format |
HHIS |
HHIS |
Note:
Non-DBC/SQL |
Conditions |
HOLD |
HOLD |
An |
none |
An |
An |
Dn |
none |
Dn |
D8 |
Fn |
none |
Dn |
D8 |
In |
n EQ 1 or 2 |
In |
I2 |
Pn.m |
n < 18 |
Pn.m |
P8 |
date |
date format |
date |
DATE |
TXnn |
TEXT field |
TXnn |
TX |
Note:
Non-SQL USAGE |
Conditions |
HOLD USAGE |
HOLD ACTUAL |
An |
none |
An |
An |
Dn |
none |
Dn |
D8 |
Fn |
none |
Fn |
F4 |
In |
n EQ 1 or 2 |
In |
I2 |
Pn.m |
n LE 31 |
Pn.m |
P(trunc((n+2)/2)) |
date |
Date format |
date |
DATE |
TXnn |
TEXT field |
TXnn |
TX |
Note:
Non-SQL USAGE |
Conditions |
HOLD USAGE |
HOLD ACTUAL |
An |
none |
An |
An |
Dn |
none |
D20.2 |
D8 |
In |
none |
I11 |
I4 |
Pn.m |
n LE 31 |
Pn.m |
P(trunc((n+2)/2)) |
date |
Date format |
HYYMDS |
H08 |
TXnn |
TEXT field |
TXnn |
TX |
Information Builders |