In this section: |
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 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 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 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 DB2, SQLDBC, SQLIDMS, or SQLORA option either in the report request or after the report has printed. The adapter generates a single-table Master and Access File, and it creates and loads one RDBMS table. If the report request uses the display command 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 adapter creates a unique index on any BY fields.
If you attempt to issue the HOLD FORMAT sqlengine command without first installing the adapter, the following error messages are generated:
(FOC1488)SQL INTERFACE IS NOT INSTALLED
(FOC1479)ERROR CONNECTING TO SQL DATABASE
Note: Adapter Commands describes how to control index space parameters with the Adapter for DB2, IDMS/SQL, or Oracle SET IXSPACE command.
The RDBMS table name that results from the extract must not already exist. (See Adapter Commands for a discussion of 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 [TABLENAME table] [CONNECTION con] [DROP]
where:
Is a name for the extract Master File. If the TABLENAME attribute is not specified, it is also the name of the resulting table. The default name is HOLD. Maximum length depends on the table name length and format for each adapter (including a period to separate the creator ID from the table name). All characters become the TABLENAME value in the Access File. Long Master File names are supported. If the HOLD command includes a long AS name, both the Master and Access File names will be long. The Master and Access Files will be named according to the procedure described in Describing Tables to FOCUS.
Unless the TABLENAME attribute is specified, the AS name also becomes the table name and is included in the Access File. If the AS name specified in the HOLD command is longer than the table name length supported by the RDBMS, the table cannot be created.
Note: If the name contains a period (.), the characters preceding it are treated as the creator ID. Characters following the period become the file description name and the FILENAME value in the Master File. Consult Describing Tables to FOCUS for information about creator IDs and TABLENAME values.
Identifies the type of RDBMS table created. Valid values are:
SQL or DB2 indicates that the output data source is stored as a table in DB2. DB2 is a synonym for SQL.
SQLDBC indicates that the output data source is stored as a Teradata table.
SQLIDMS indicates that the output data source is stored as a CA-IDMS table.
SQLORA indicates that the output data source is stored as an Oracle table.
Is the name of the resulting table in the DBMS. It must conform to the name length supported by the RDBMS or the table cannot be created.
Is a connection name (CLI only).
Before implementing the HOLD command to create the table, drops an existing table with the same name.
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 allocate the data sets that contain the generated Master and Access files to permanent partitioned data sets. The generated Master and Access Files are created as members of the partitioned data sets allocated to DDNAMEs HOLDMAST and HOLDACC. If you do not allocate those DDNAMEs, they are allocated dynamically and deleted at the end of the session. To permanently retain the new file descriptions, allocate HOLDMAST to a permanent partitioned data set and HOLDACC to a second permanent partitioned data set. If you allocate HOLDMAST and HOLDACC, do not specify DCB parameters.
This example converts the FOCUS PROD data source 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 command is a single-table description. It contains the attributes described in Describing Tables to FOCUS. Following is a list of the generated keyword/valuepairs:
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 field name 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:
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, $
When the AS name is longer than the supported length for table names in DB2 on z/OS, the following messages are generated:
> 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 name IS TOO : LONG. MAXIMUM ALLOWABLE SIZE IS xx : 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 command 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:
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.
Reference: |
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.
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 n GT 2 MISSING=ON
|
In In In
|
I2 I4 I4
|
Pn . m |
n LE 31 MISSING=ON
|
Pn . m Pn, n<15
|
P(trunc((n+2)/2)) P8
|
date |
Date format |
date |
DATE |
TXnn |
TEXT field |
TXnn |
TX |
HYYMDm |
Timestamp field |
HYYMDm |
HYYMDm |
HHIS |
Time format |
HHIS |
HHIS |
Note:
Non-DBC/SQLUSAGE |
Conditions |
HOLDUSAGE |
HOLDACTUAL |
---|---|---|---|
An |
none |
An |
An |
Dn |
none |
Dn |
D8 |
Fn |
none |
Dn |
D8 |
In |
n EQ 1 or 2 n GT 2 MISSING=ON
|
In In In
|
I2 I4 I4
|
Pn.m |
n < 18 n = 18
|
Pn.m Pn.m
|
P8P10 |
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 n GT 2 MISSING=ON
|
In In In
|
I2I4I4 |
Pn . m |
n LE 31 MISSING=ON
|
Pn.m Pn.m, n£15
|
P(trunc((n+2)/2))P8 |
date |
Date format |
date |
DATE |
TXnn |
TEXT field |
TXnn |
TX |
Note:
In this section: How to: Reference: |
You can create a report output file, that is, a HOLD file, as a native DBMS temporary table. This increases performance by keeping the entire reporting operation on the DBMS server, instead of downloading data to your computer and then back to the DBMS server.
For example, if you temporarily store report output for immediate use by another procedure, storing it as a temporary table instead of creating a standard HOLD file avoids the overhead of transmitting the interim data to your computer.
The temporary table columns are created from the following report elements
except for those for which NOPRINT is specified.
The temporary table that you create from your report will be the same data source type (that is, the same DBMS) as the data source from which you reported. If the data source from which you reported contains multiple tables, all must be of the same data source type and reside on the same instance of the DBMS server.
You can choose between several types of table persistence.
You can create extract files as native DBMS tables with the following adapters:
The syntax to save report output as a native DBMS temporary table is
ON TABLE HOLD [AS filename]FORMAT SAME_DB [PERSISTENCE persistValue]
where:
Specifies the name of the HOLD file. If you omit AS filename, the name of the temporary table defaults to "HOLD".
Because each subsequent HOLD command overwrites the previous HOLD file, it is recommended to specify a name in each request to direct the extracted data to a separate file, thereby preventing an earlier file from being overwritten by a later one.
Specifies the type of table persistence and related table properties. This is optional for DBMSs that support volatile tables, and required otherwise. For information about support for volatile tables for a particular DBMS, see Temporary Table Properties for SAME_DB Persistence Values, and consult your DBMS vendor's documentation.
Is one of the following:
Specifies that the table is local to the DBMS session. A temporary synonym—a Master File and Access File—is generated automatically; it expires when the server session ends.
This is the default persistence setting for all DBMSs that support volatile tables.
For information about support for the volatile setting, and about persistence and other table properties, for a particular DBMS, see Temporary Table Properties for SAME_DB Persistence Values, and consult your DBMS vendor's documentation.
Specifies that while the table exists, its definition will be visible to other database sessions and users though its data will not be. A permanent synonym—a Master File and Access File—is generated automatically.
For information about support for the global temporary setting, and about persistence and other table properties, for a particular DBMS, see Temporary Table Properties for SAME_DB Persistence Values, and consult your DBMS vendor's documentation.
Specifies that a regular permanent table will be created. A permanent synonym—a Master File and Access File—is generated automatically.
The following chart provides additional detail about persistence and other properties of temporary tables of different data source types that are supported for use with HOLD format SAME_DB.
Informix
Microsoft SQL Server
MySQL
A volatile table is created using the CREATE TEMP TABLE command with the WITH NO LOG option. The definition and the data persist, and are visible, only within the current session.
A volatile table is created as a local temporary table whose name is prefixed with a single number sign (#). Therefore, the name of a volatile table used as a HOLD file is the name specified by the HOLD phrase, prefixed with a number sign (#). The table's definition and the data persist, and are visible, only within the current session.
A volatile table is created using the CREATE TEMPORARY TABLE command. A temporary table persists and is visible only within the current session (connection). If a temporary table has the same name as a permanent table, the permanent table becomes invisible.
This type of table is not supported by Informix.
The name of a global temporary table is prefixed with two number signs (##). Therefore, the name of a global temporary table used as a HOLD file is the name specified by the HOLD phrase, prefixed with two number signs (##). The table is dropped automatically when the session that created the table ends and all other tasks have stopped referencing it. The table's definition and data are visible to other sessions.
This type of table is not supported by MySQL.
DBMS |
VOLATILE |
GLOBAL_TEMPORARY |
---|---|---|
DB2 |
DB2: on UNIX, Windows, and DB2 for z/OS: a volatile table is created using the DECLARE GLOBAL TEMPORARY TABLE command with the ON COMMIT PRESERVE ROWS option. Declared global temporary tables persist and are visible only within the current session (connection). SESSION is the schema name for all declared global temporary tables. |
DB2 Release 7.1 and up for z/OS only: a global temporary table is created using the CREATE GLOBAL TEMPORARY TABLE command. The definition of a created global temporary table is visible to other sessions, but the data is not. The data is deleted at the end of each transaction (COMMIT or ROLLBACK command). The table definition persists after the session ends. |
Oracle |
This type of table is not supported by Oracle. |
The table's definition is visible to all sessions; its data is visible only to the session that inserts data into it. The table's definition persists for the same period as the definition of a regular table. |
Teradata |
A volatile table definition and data are visible only within the session that created the table and inserted the data. The volatile table is created with the ON COMMIT PRESERVE ROWS option. |
A global temporary table persists for the same duration as a permanent table. The definition is visible to all sessions, but the data is visible only to the session that inserted the data. The global temporary table is created with the ON COMMIT PRESERVE ROWS option. |
Each HOLD file column is assigned its name:
A primary key or an index is created for the HOLD table. The key or index definition is generated from the sort (BY) keys of the TABLE command, except for undisplayed sort keys (that is, sort keys for which NOPRINT is specified). To determine whether a primary key or an index will be created:
Information Builders |