Features Added in FOCUS 7.7.06

In this section:

The following features were added as of FOCUS 7.7.06

Creating Synonyms for DB2 Data Sources

How to:

Reference:

The AUTOSYN facility creates synonyms (Master and Access Files) for existing tables using RDBMS catalog definitions and user selections. All data types supported by the adapter are available for the generated Master Files.

Only single-segment Master and Access Files can be created with this facility. Each synonym created describes a single table or a view of a single table.

Master Files are generated in the first writable data set allocated to DDNAME MASTER. Access Files are generated in the first writable data set allocated to DDNAME ACCESS, which is a required DDNAME for using this facility to generate synonyms. For running requests and for viewing or editing synonyms, both the ACCESS and FOCSQL DDNAMEs are supported.

Reference: Overview of the AUTOSYN Facility

When you invoke the AUTOSYN facility, a screen displays on which you enter search fields and processing options.

The search fields are used to generate a list of candidate tables.

Once the list of tables has been generated, you can select tables from the list and select a processing option by pressing a Function key.

The synonyms processed by the AUTOSYN facility do not have to be generated by the facility. The following processing options are available:

  • Create synonyms.
  • View/Edit Master Files.
  • View/Edit Access Files.
  • Issue the CHECK FILE command.
  • Execute test queries.

Procedure: How to Create Synonyms for DB2 Tables

  1. Issue the following command from the FOCUS prompt.
    EX AUTOSYN

    The SQL Master File Generation Facility opens, as shown in the following image:

  2. Enter one or more search values and processing options on this screen.

    You can enter information into one or more of the search fields at the top of the screen. Based on the values you enter, a list of candidate tables will be generated when you press F2.

    You can enter specific values or a pattern that uses wildcard characters. The underscore character (_) indicates that any single character in that position will be considered a match to the pattern. A percent symbol (%) indicates that a variable number of characters in that position will be considered a match to the pattern. A blank search field accepts any value found for that field.

    Following is a list of the search fields. To proceed from one field to the next, press the Tab key. To move backward, press Shift+Tab.

    • Location.
    • Database.
    • Creator.
    • Table name.

    The following entry fields on the screen have default values that you can change:

    • Overwrite existing MASTER. The default is N (No). To overwrite an existing synonym with the same name, enter Y.
    • Case sensitive. The default is Y (Yes). To turn off case sensitivity, enter N.
    • Max Rows. By default, all matching tables display, and you can scroll through the list using the F7 and F8 keys. To limit the number of lines displayed, enter a number.

    Help is available for each entry field by pressing F1 when the cursor is in the field.

  3. Press F2 to generate a list of tables that match the criteria you specified in the entry fields.

    A list similar to the following displays:

    You can then select one or more tables from this list by entering S in the S column.

    By selecting rows from this list, you can:

    • Create synonyms (F4).
    • View/Edit Master Files (F5).
    • View/Edit Access Files (F6).
    • Issue the CHECK FILE command (F9).
    • Run test queries (F10).

    The list of tables has the following columns:

    • S. Enter S on each row you want to select for the operation to be performed.
    • MFD Name. Is the default synonym name that will be generated when you press F4. You can type over this name to specify your own synonym name. The name can be up to eight characters long. The default name is the table name, if it is less than or equal to eight characters. If the table name is more than eight characters, the default name is composed of the first four characters of the table name appended with the line number.
    • Creator/TableName. Contains the Creator and Table name for that row.
    • Location. Contains the Location name for that row. A blank represents a local table.
  4. Enter S in the S column on one or more lines, and press the Function key that corresponds to the operation you wish to perform.

Reference: Results of the AUTOSYN Facility Processing Options

Synonym Generation Results

If you used the synonym generation processing option (F4), the following changes display on the list:

  • On each line for which the operation was successful, P displays in the S column, and both the P and the synonym name are light blue.
  • On each line for which the operation was unsuccessful, F displays in the S column, and both the P and the synonym name are red. In addition, a message displays at the bottom of the screen indicating what the problem was, as shown on the following screen:

    A synonym named EMPL036 was generated successfully, but the DATETIME synonym was not generated because the synonym already exists, and Overwrite existing MASTER is set to N.

    Master Files are generated in the first writable data set allocated to DDNAME MASTER. Access Files are generated in the first writable data set allocated to DDNAME ACCESS. DDNAME ACCESS is a required DDNAME for using this facility to generate synonyms. For viewing or editing synonyms or for running requests against relational data sources, both the FOCSQL and ACCESS DDNAMEs are supported.

View/Edit Master and Access Files Results

If your processing option was F5 to view Master Files or F6 to view Access Files, the TED editor opens, as shown in the following image.

You can edit the Master or Access File, if necessary.

To exit TED, leaving the file unchanged:

  • Press F3 if you did not make changes,
  • Issue the QQ command if you did make changes.

To exit TED and save changes, issue the FILE command.

If you selected multiple tables, the Master or Access File for the next selected table will open. After the last selected Master or Access File is processed, you return to the list of candidate tables.

CHECK FILE Results

If your processing option was F9 to issue the CHECK FILE command, an output screen will display, as shown in the following image.

To exit the CHECK FILE output screen, enter EXIT at the WAIT prompt.

Test Query Results

If your processing option was F10 to run test queries, Hotscreen opens, as shown in the following image.

To exit Hotscreen at the last page of output, press Enter.

Reference: Properties of Generated Synonyms

In the Master File:

  • The FILENAME and SEGMENT values are the synonym (member) name you specified on the initial screen.
  • The SEGTYPE value is always S0.
  • Field declarations for primary key columns are listed first, followed by those for non-key fields.
  • FIELDNAME and ALIAS values are the full RDBMS column names.
  • Data types are determined as specified in the Data Type Support section of the Relational Adapter User’s Manual. Field lengths for USAGE and ACTUAL formats are calculated automatically.
  • The MISSING attribute is included and is set ON if the RDBMS table definition allows NULLs.

In the Access File:

  • The SEGNAME value matches the corresponding SEGMENT value in the Master File.
  • The TABLENAME value is composed of the creator name and the table name. If a location was specified, the location, creator, and table name compose the TABLENAME value.
  • The KEYS value is supplied. It is determined using existing RDBMS indexes. This also determines the order in which to place fields in the Master File. KEYS is set to zero if a unique index does not exist or if an RDBMS view is described.

    Note: In the case of a view, the unique indexes are described on the underlying tables, not on the view. They may not be valid as a primary key for the view. If possible, edit the Master and Access Files to reflect the index structure of the base tables.

  • The optional keyword DBSPACE is omitted.

You may need to edit the generated Master File or its corresponding Access File if:

  • You prefer field names different from the generated names.
  • There are RDBMS data types in the tables or views that the adapter does not support. Field declarations are not generated for columns with unsupported data types. You can add the field declarations yourself.
  • A unique index does not exist, or you want to use a different index from the selected one. If the table or view has a primary key, specify a value greater than zero for the KEYS attribute, and rearrange the fields in the Master File so that the columns comprising the primary key are described first.
  • Certain fields are classified for security reasons. To add security, delete field declarations or include FOCUS DBA attributes.
  • You require options such as DEFINE fields and KEYORDER.

Reference: Function Key Assignments

The following table describes the function of each Function key.

Function Key

Description

F1

Displays context sensitive Help.

Note: If you press F1 twice, a list of Function key assignments is displayed.

F2

Generate a list of candidate tables using the search fields at the top of the screen.

F3

Exit the current screen.

F4

Generate synonyms for selected tables.

F5

View/Edit Master Files of selected tables.

F6

View/Edit Access Files of selected tables.

F7

Scroll down.

F8

Scroll up.

F9

Issue the CHECK FILE command for the selected tables.

F10

Run test queries for the selected tables.

Creating Indexes for an Existing Table

How to:

Reference:

A synonym for a table in a relational data source can contain declarations in the Access File specifying which columns should have indexes.

When you issue a CREATE FILE command for a table, an index is created in the relational DBMS for the primary key and for each index specified in the Access File.

If you want to create a table without creating all of the indexes at that time, you can omit the index declarations from the Access File and issue the CREATE FILE command to create only the table and the index on the primary key. Then, at a later time, you can add the index declarations to the Access File and issue the CREATE FILE command with the INDEXESONLY phrase. The option of adding the indexes later makes loading data into a relational table much faster.

Syntax: How to Create Indexes for an Existing Table

CREATE FILE [app/]synonym INDEXESONLY 

where:

app

Is the application folder in which the synonym resides.

synonym

Is the synonym for the existing table.

Reference: Usage Notes for CREATE FILE With INDEXESONLY

  • CREATE FILE always creates an index on the primary key.
  • CREATE FILE with INDEXESONLY recreates the index on the primary key and creates all indexes declared in the Access File.

Optimization of Full Outer Joins

How to:

The FOCUS join command and conditional join command have a FULL OUTER join option.

A full outer join returns all rows from the source data source and all rows from the target data source. Where values do not exist for the rows in either data source, null values are returned. FOCUS substitutes default values on the report output (blanks for alphanumeric columns, the NODATA symbol for numeric columns).

The full outer join is only supported for use with those relational data sources that support this type of join, in which case the FOCUS join syntax is optimized (translated to the full outer join SQL syntax supported by the RDBMS). Use of this syntax for any data source that does not support a full outer join produces an error message.

Syntax: How to Specify a Full Outer Join

The following syntax generates a full outer equijoin based on real fields:

JOIN FULL_OUTER hfld1 [AND hfld2 ...] IN table1 [TAG tag1] TO {UNIQUE|MULTIPLE} cfld [AND cfld2 ...] IN table2 [TAG tag2] [AS joinname]
END

where:

hfld1

Is the name of a field in the host table containing values shared with a field in the cross-referenced table. This field is called the host field.

AND hfld2...

Can be an additional field in the host table. The phrase beginning with AND is required when specifying multiple fields.

  • For relational adapters that support multi-field and concatenated joins, you can specify up to 16 fields. See your adapter documentation for specific information about supported join features.
IN table1

Is the name of the host table.

TAG tag1

Is a tag name of up to 66 characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in the host table.

The tag name for the host table must be the same in all the JOIN commands of a joined structure.

TO [UNIQUE|MULTIPLE] crfld1

Is the name of a field in the cross-referenced table containing values that match those of hfld1 (or of concatenated host fields). This field is called the cross-referenced field.

Note: UNIQUE returns only one instance and, if there is no matching instance in the cross-referenced table, it returns null values.

Use the MULTIPLE parameter when crfld1 may have multiple instances in common with one value in hfld1. Note that ALL is a synonym for MULTIPLE, and omitting this parameter entirely is a synonym for UNIQUE.

AND crfld2...

Is the name of a field in the cross-referenced table with values in common with hfld2.

Note: crfld2 may be qualified. This field is only available for adapters that support multi-field joins.

IN crfile

Is the name of the cross-referenced table.

TAG tag2

Is a tag name of up to 66 characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in cross-referenced tables. In a recursive join structure, if no tag name is provided, all field names and aliases are prefixed with the first four characters of the join name.

The tag name for the host table must be the same in all the JOIN commands of a joined structure.

AS joinname

Is an optional name of up to eight characters that you may assign to the join structure. You must assign a unique name to a join structure if:

  • You want to ensure that a subsequent JOIN command does not overwrite it.
  • You want to clear it selectively later.
  • The structure is recursive.

Note: If you do not assign a name to the join structure with the AS phrase, the name is assumed to be blank. A join without a name overwrites an existing join without a name.

END

Required when the JOIN command is longer than one line. It terminates the command and must be on a line by itself.

The following syntax generates a DEFINE-based full outer join:

JOIN FULL_OUTER deffld WITH host_field ... 
     IN table1 [TAG tag1]
     TO [UNIQUE|MULTIPLE] 
     cr_field IN table2 [TAG tag2] [AS joinname]
END

where:

deffld

Is the name of a virtual field for the host file (the host field). The virtual field can be defined in the Master File or with a DEFINE command.

WITH host_field

Is the name of any real field in the host segment with which you want to associate the virtual field. This association is required to locate the virtual field.

The WITH phrase is required unless the KEEPDEFINES parameter is set to ON and deffld was defined prior to issuing the JOIN command.

To determine which segment contains the virtual field, use the ? DEFINE query after issuing the DEFINE command.

IN table1

Is the name of the host table.

TAG tag1

Is a tag name of up to 66 characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in host tables.

The tag name for the host table must be the same in all JOIN commands of a joined structure.

TO [UNIQUE|MULTIPLE] crfld1

Is the name of a real field in the cross-referenced table whose values match those of the virtual field. This must be a real field declared in the Master File.

Note: UNIQUE returns only one instance and, if there is no matching instance in the cross-referenced table, it returns null values.

Use the MULTIPLE parameter when crfld1 may have multiple instances in common with one value in hfld1. Note that ALL is a synonym for MULTIPLE, and omitting this parameter entirely is a synonym for UNIQUE.

IN crfile

Is the name of the cross-referenced table.

TAG tag2

Is a tag name of up to 66 characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in cross-referenced tables. In a recursive joined structure, if no tag name is provided, all field names and aliases are prefixed with the first four characters of the join name.

The tag name for the host file must be the same in all JOIN commands of a joined structure.

AS joinname

Is an optional name of up to eight characters that you may assign to the joined structure. You must assign a unique name to a join structure if:

  • You want to ensure that a subsequent JOIN command does not overwrite it.
  • You want to clear it selectively later.
  • The structure is recursive, and you do not specify tag names.

If you do not assign a name to the joined structure with the AS phrase, the name is assumed to be blank. A join without a name overwrites an existing join without a name.

END

Required when the JOIN command is longer than one line. It terminates the command and must be on a line by itself.

The following syntax generates a full outer conditional join:

JOIN FULL_OUTER FILE table1 AT hfld1 [WITH hfld2] [TAG tag1]
     TO {UNIQUE|MULTIPLE} 
     FILE table2 AT crfld [TAG tag2] [AS joinname]
     [WHERE expression1;
     [WHERE expression2;
     ...]
END

where:

table1

Is the host Master File.

AT

Links the correct parent segment or host to the correct child or cross-referenced segment. The field values used as the AT parameter are not used to cause the link. They are used as segment references.

hfld1

Is the field name in the host Master File whose segment will be joined to the cross-referenced table. The field name must be at the lowest level segment in its data source that is referenced.

tag1

Is the optional tag name that is used as a unique qualifier for fields and aliases in the host table.

hfld2

Is a table column with which to associate a DEFINE-based conditional JOIN. For a DEFINE-based conditional join, the KEEPDEFINES setting must be ON, and you must create the virtual fields before issuing the JOIN command.

MULTIPLE

Specifies a one-to-many relationship between table1 and table2. Note that ALL is a synonym for MULTIPLE.

UNIQUE

Specifies a one-to-one relationship between table1 and table2. Note that ONE is a synonym for UNIQUE.

Note: The join to UNIQUE will return only one instance of the cross-referenced table, and if this instance does not match based on the evaluation of the WHERE expression, null values are returned.

crfile

Is the cross-referenced Master File.

crfld

Is the join field name in the cross-referenced Master File. It can be any field in the segment.

tag2

Is the optional tag name that is used as a unique qualifier for fields and aliases in the cross-referenced table.

joinname

Is the name associated with the joined structure.

expression1, expression2

Are any expressions that are acceptable in a DEFINE FILE command. All fields used in the expressions must lie on a single path.

END

The END command is required to terminate the command and must be on a line by itself.

Example: Optimizing a Full Outer Join of DB2 Tables

The following requests generate two tables to join, and then issues a request against the join. The tables are generated using the WFLITE sample.

The following request generates the WF_SALES table. The field ID_PRODUCT will be used in the full outer join command. The generated table will contain ID_PRODUCT values from 2150 to 4000:

TABLE FILE WFLITE
SUM GROSS_PROFIT_US PRODUCT_CATEGORY PRODUCT_SUBCATEG
BY ID_PRODUCT
WHERE ID_PRODUCT FROM 2150 TO 4000
ON TABLE HOLD AS WF_SALES FORMAT DB2
END

The following request generates the WF_PROD table. The field ID_PRODUCT will be used in the full outer join command. The generated table will contain ID_PRODUCT values from 3000 to 5000:

TABLE FILE WFLITE
SUM PRICE_DOLLARS PRODUCT_CATEGORY PRODUCT_SUBCATEG PRODUCT_NAME
BY ID_PRODUCT
WHERE ID_PRODUCT FROM 3000 TO 5000
ON TABLE HOLD AS WF_PROD FORMAT DB2
END

The following request issues the JOIN command and displays values from the joined tables:

SET TRACEUSER=ON
SET TRACESTAMP=OFF
SET TRACEOFF=ALL
SET TRACEON = STMTRACE//CLIENT
JOIN FULL_OUTER ID_PRODUCT IN WF_PROD TAG T1 
TO ALL ID_PRODUCT IN WF_SALES TAG T2
END 
TABLE FILE WF_PROD
PRINT T1.ID_PRODUCT AS 'Product ID' 
PRICE_DOLLARS AS Price
T2.ID_PRODUCT AS 'Sales ID' 
GROSS_PROFIT_US
BY T1.ID_PRODUCT NOPRINT
ON TABLE SET PAGE NOPAGE
END

The trace shows that the full outer join was optimized (translated to SQL) so that DB2 could process the join:

 SELECT
T1."ID_PRODUCT",
T1."PRICE_DOLLARS",
T2."E01",
T2."E021"
 FROM
( WF_PROD T1
 FULL OUTER JOIN WF_SALES T2
 ON T2."E01" = T1."ID_PRODUCT" )
 ORDER BY
T1."ID_PRODUCT"
 FOR FETCH ONLY;

The output has a row for each ID_PRODUCT value that is in either table.

Product ID                 Price   Sales ID                Gross Profit
----------                 -----   --------                ------------
         .                     .       2158                  $11,267.75
         .                     .       2157                   $6,223.34
         .                     .       2156                  $14,484.75
         .                     .       2155                  $12,472.93
         .                     .       2154                  $19,913.65
         .                     .       2153                   $7,291.10
         .                     .       2152                   $6,766.45
         .                     .       2151                   $7,172.24
         .                     .       2167                   $6,771.26
         .                     .       2166                  $12,469.45
         .                     .       2165                   $8,540.53
         .                     .       2164                   $5,615.33
         .                     .       2163                  $21,347.98
         .                     .       2162                   $9,197.81
         .                     .       2161                   $8,683.00
         .                     .       2160                   $7,194.15
         .                     .       2159                   $9,015.75
      3001             47,988.00       3001                  $12,786.30
      3002             34,990.00       3002                   $5,586.10
      3003             30,591.00       3003                  $12,399.15
      3004             44,187.00       3004                   $8,434.95
      3005             30,057.00       3005                   $8,987.80
      3006             25,348.05       3006                   $6,422.59
      3007             23,607.00       3007                   $8,354.60
      3008             42,898.57       3008                  $18,469.01
      3009             48,139.00       3009                  $22,542.75
      3010             44,850.00       3010                  $16,722.15
      3011             28,078.44       3011                  $18,204.82
      3012             31,146.00       3012                  $19,739.45
      3013             27,208.00       3013                  $17,983.00
      3014             23,968.59       3014                  $19,996.09
      3015             29,061.45       3015                  $17,420.72
      4012             43,998.35          .                           .
      4013             24,749.89          .                           .
      4014             33,966.00          .                           .
      4015             20,998.95          .                           .
      4016             32,899.06          .                           .
      4017             26,399.67          .                           .
      4018             39,920.00          .                           .
      5000             23,799.15          .                           .

Rows with ID_PRODUCT values from 2150 to 2167 are only in the WF_SALES table, so the columns from WF_PROD display the NODATA symbol. Rows with ID_PRODUCT values above 4000 are only in the WF_PROD table, so the columns from WF_SALES display the NODATA symbol. Rows with ID_PRODUCT values from 3000 to 4000 are in both tables, so all columns have values.

Support for Discontiguous Key Definition in the Access File

How to:

In prior releases, fields participating in the key to a table had to be described first in the Master File. The number of key fields was identified by the KEYS=n attribute in the Access File, where n is the number of key fields.

While this method is still supported by the relational adapters, it has been deprecated. In Version 7 Release 7.06, new syntax is available that does not require any reordering of the fields in the Master File. If an Access File with the KEYS=n syntax is opened in the Synonym Editor, the Synonym Editor will convert it to the new syntax.

Syntax: How to Specify Discontiguous Keys in the Access File

Key fields in the Master File can be listed in the order established by the relational DBMS or in any order that is convenient. In the Access File, identify the key fields with the following syntax:

KEY=fld1/fld2/.../fldn

where:

fld1, fld2,...,fldn

Are the fields that participate in the key.

Example: Specifying Discontiguous Keys in the Access File

The following is a Master File for an Oracle table:

FILENAME=BMKEY, SUFFIX=SQLORA  , $
  SEGMENT=BMKEY, SEGTYPE=S0, $
    FIELDNAME=F1INT, ALIAS=F1INT, USAGE=I11, ACTUAL=I4, $
    FIELDNAME=F2CHAR4, ALIAS=F2CHAR4, USAGE=A4, ACTUAL=A4,
      MISSING=ON, $
    FIELDNAME=F3INT, ALIAS=F3INT, USAGE=I11, ACTUAL=I4,
      MISSING=ON, $
    FIELDNAME=F4CHAR6, ALIAS=F4CHAR6, USAGE=A6, ACTUAL=A6,
      MISSING=ON, $

The following Access File identifies F4CHAR6 and F1INT as the key fields, with F4CHAR6 as the high-order portion of the key, even though it is not first in the Master File:

SEGNAME=BMDKEY_KEY_FLDLST, 
   TABLENAME=R729999D.BMDKEY, 
   CONNECTION=<local>, 
   KEY=F4CHAR6/F1INT, $

Optimization of Simplified Character Functions

Simplified character functions have streamlined parameter lists, similar to those used by SQL functions. They are optimized against a wide variety of Relational data sources. The simplified character functions introduced in this release are:

The SQL Optimization Report provides optimization information for each function by adapter.

Optimization of Simplified Date and Date-Time Functions

Simplified date and date-time functions have streamlined parameter lists, similar to those used by SQL functions. They are optimized against a wide variety of Relational data sources. The simplified date and date-time functions introduced in this release are:

The SQL Optimization Report provides optimization information for each function by adapter.

Optimization of Legacy Character and Numeric Functions

The following functions have been optimized for most SQL adapters, as reflected in the SQL Optimization Report.

Optimization of Date and Date-Time Functions

The following functions are optimized as reflected in the SQL Optimization Report.

Automatically Generating FORMAT SQL_SCRIPT for HOLD Files

This feature implements a SET command that generates HOLD files as SQL_SCRIPT files when no format is specified on the ON TABLE HOLD command.

Note: If the adapter cannot generate SQL requests for a complex TABLE request (due to expression complexity or other reasons), the system automatically downgrades the HOLDFORMAT setting to BINARY for that request only. The procedure will run, but more slowly (with extract to disk). This can be used for application conversions to SQL_SCRIPT, such as BCEE-generated or MFACT-generated procedures.

Adapter for Teradata Support for Reading PERIOD and INTERVAL Data Types

The Adapter for Teradata now supports read access to the PERIOD and INTERVAL data types.

The PERIOD data type is mapped to Alphanumeric (An), where n = 24 to 60, depending on the native PERIOD format.

The INTERVAL data type (all formats) is mapped as An, where n = 2 to 21, depending on the INTERVAL format.

Adapter for Teradata Support for Long Table and View Names

Teradata introduced Extended Object Name (EON) in v.14.1. The Adapter for Teradata now supports table and view names (containing multi-byte characters) with length up to 128-bytes.

Adapter for Teradata Support for Number Data Type

The Adapter for Teradata now supports the NUMBER(p,s) data type that was introduced in Teradata Version 14. Numeric values with up to 31 digits are supported.

Selectively Controlling FOCUS Function Optimization Through FEATOPT

The optimization of some FOCUS features and functions can now be controlled using the FEATOPT SET command. This enables users to switch off SQL optimization for a particular function or feature when the optimization might produce unsatisfactory results.

The syntax is:

ENGINE SQL<engine> SET FEATOPT <focus_feature> OFF

The default value is ON, which means that the given function will be passed to SQL or the feature will be optimized. The setting can be applied to the following FOCUS features and functions:

  • ** (power operator: x**y)
  • IFTHENELSE
  • ABS
  • LOCASE
  • DATEADD
  • LOCASV
  • DATECVT
  • LOG
  • DATEDIF
  • RANK (BY [HIGHEST/LOWEST])
  • DECODE
  • SQLFUN (SQL. functions)
  • DEDIT
  • SQRT
  • DEFFUN (defined functions)
  • SUBSTR
  • DPART
  • SUBSTV
  • DSUBSTR
  • TRIMV
  • EDIT
  • UPCASE
  • HDIFF
  • UPCASV
  • HADD
  • S_CONCAT (strong concatenation)
  • HDATE
  • W_CONCAT (weak concatenation)
  • HPART
 

 

Support for SELECT ON TABLE HOLD FORMAT SAME_DB

An SQL SELECT statement with all the sources in the same relational database can now be used with an ON TABLE HOLD AS name FORMAT SAME_DB command. This uses the underlying database capabilities, such as INSERT INTO ... SELECT, that provide much faster throughput than alternative methods.

Full Synonym Support Added for SQL Strings

Synonyms created for SQL strings without parameters can now be used in the following commands/situations:

The SQL strings will be processed as subqueries embedded in a FROM clause of the generated SELECT query. The new behavior is triggered by the presence of a SUBQUERY=Y keyword in the Access File describing the location of the SQL string file. SUBQUERY=Y is not permitted for Access Files describing SQL strings that use SQL parameter markers, for example '?' or ':001'.

AUTOINCREMENT for PACK Fields Added

Surrogate Keys Support has been enhanced and now includes fields defined with the PACK data type. Therefore, auto-incrementing can now be assigned to PACK data type fields.

The AUTOINCREMENT field uses the numeric data type with the widest value range allowed by a particular DBMS for the autonumbering: DECIMAL, BIGINT, SERIAL, SERIAL8, or BIGSERIAL.

AUTOINCREMENT is supported by the following adapters:

BY HIERARCHY Reporting Available From SQL and Hold Files

BY HIERARCHY reporting now can be applied to relational data sources. The end user is responsible for properly representing the hierarchy in the Master File. The Dimension Builder in the Data Management Console enables you to assign the properties of the hierarchy.

Using Segment Names as Tags When Generating SQL

The default tag name used by the FOCUS SQL generator is T1, T2, and so on. A new setting has been introduced that enables you to assign tag names to match the segment names that contain the referenced fields. To switch to using the SEGNAMEs as tag names, use the following setting:

SQL engine SET SQLTAG SEGNAME

To switch back to the T1, T2 tag names in the generated SQL, which is the default, use the following setting:

SQL engine SET SQLTAG SEGNUM

Support for FOCUS Amper Variables as SQL String Parameters

The ability to run a request against a synonym for an SQL string has been enhanced to allow the parameterization of the SQL string using Dialogue Manager global variables. After the synonym has been created against the relational adapter where the SQL will be processed, global variables can be added to the source SQL file. The Synonym Editor is then used to add the Variable Declarations.

The following example illustrates this feature. The .sql file contains the following:

SELECT COLUMNA, COLUMNB, COLUMNC FROM test1
WHERE COLUMNA = 'test'

The synonym created will have three fields. The SQL can now be edited to add a global variable in place of the WHERE value test:

WHERE COLUMNA = &&VARIABLE1

The Synonym Editor is then used to add the variable declaration:

FILENAME=test1, SUFFIX=SQLMSS , $
 VARIABLE NAME=&&VARIABLE1, QUOTED=ON, $

The global variable can be set prior to running a request:

-SET &&VARIABLE1 = 'NEWVALUE'
TABLE FILE TEST1
PRINT *
END

Adapter for Oracle Support for XMLType Data Type

The Adapter for Oracle can now describe a column defined in the DBMS as native XMLType.

Oracle XMLType can be accessed through the getCLOBVal() native method using any of two techniques:

For example, with an Oracle table with following structure:

ORAXML 
---------------------
INTFLD  INT
XMLFLD XMLType

The first technique requires you to use Create View in Oracle:

CREATE VIEW ORAXML_V (I_FLD,X_FLD)
AS
SELECT a.INTFLD,
       a.XMLFLD.getCLOBVal()
FROM ORAXML a;

You can then use the standard approach which combines Oracle and XML synonyms, as described in the documentation for the Adapter for XML.

The second technique does not require using Create View in Oracle. The virtual field can be used instead.

For example, assume the synonym ORAXML_S is created for the table above and the XMLFLD is mapped as TX50L, TX. Then the following statements:

DEFINE FILE ORAXML_S
XMLFLD/A32767 WITH INTFLD=DB_EXPR(T1.XMLFLD.getCLOB());
END
TABLE FILE ORAXML_S PRINT XMLFLD WHERE INTFLD EQ <value>
END

will be optimized as:

SELECT
  (T1.XMLFLD.getCLOBVal()),
  T1."INTFLD"
  FROM 
  ORAXML T1
  WHERE 
  T1."INTFLD" = <value>

and will bring Oracle XMLType data into the report.

Adapter for Oracle Support for NCLOB Data Type

The Adapter for Oracle now can describe report and update Oracle columns that are defined as NCLOB (National Character Large Objects) when FOCUS is configured for Unicode.

Note:
  • The Oracle NCLOB columns are described in the Master File as USAGE=TX50, ACTUAL=TX.
  • As with CLOB, NCLOB can be used in WHERE clauses only for pattern matching, for example, %pattern%. It cannot be used for a comparison search, such as =/!=/<>/>=/<=.

SQL.Function Syntax for Direct DBMS Function Calls

Reference:

The SQL adapters can pass virtual fields that call certain SQL scalar functions to the relational engine for processing. This enables you to use SQL functions in a request even when they have no equivalent in the FOCUS language. The function must be row-based and have a parameter list that consists of a comma-delimited list of column names or constants. In order to reference the function in an expression, prefix the function name with SQL.

If the virtual field is in the Master File, both TABLE requests and those SQL requests that qualify for Automatic Passthru (APT) can access the field. If the virtual field is created by a DEFINE FILE command, TABLE requests can access the field. The function name and parameters are passed without translation to the relational engine. Therefore, the expression that creates the DEFINE field must be optimized, or the request will fail.

Reference: Usage Notes for Direct SQL Function Calls

  • The expression containing the SQL.function call must be optimized or the request will fail with the following message:
    (FOC32605) NON OPTIMIZABLE EXPRESSION WITH SQL. SYNTAX
  • The function must be a row-based scalar function and have a parameter list that consists of a comma-delimited list of column names or constants. If the function uses anything other than a list of comma separated values, the SQL. syntax cannot be used to pass it.
  • Constant DEFINE fields must be assigned a segment location using the WITH phrase.
  • Expressions should be declared as DEFINE fields, which are supported as parameters to an SQL function.
  • Data types are not supported as parameters to an SQL function. Examples of data type arguments are CHAR and INT for the CONVERT function and ISO, EUR, JIS, and USA for the CHAR function.

Example: Calling the SQL COALESCE Function in a Request

The following example creates the table GGDB2, which has columns Biscotti, Capuccino, Croissant, Espresso, and Latte, some of which are null. It then issues a TABLE request that calls the SQL function COALESCE. COALESCE returns the first column in the parameter list that does not contain a null value, if one exists.

The Master File for GGDB2 is:

FILENAME=GGDB2  , SUFFIX=SQLDS     , IOTYPE=STREAM, $
  SEGMENT=GGDB2, SEGTYPE=S0, $
    FIELDNAME=CATEGORY, ALIAS=CAT, USAGE=A11, ACTUAL=A11,
      MISSING=ON, $
    FIELDNAME=Biscotti, ALIAS=BIS, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Capuccino, ALIAS=CAP, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Croissant, ALIAS=CROI, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Espresso, ALIAS=ESP, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Latte, ALIAS=LAT, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Mug, ALIAS=MUG, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Scone, ALIAS=SCO, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $
    FIELDNAME=Thermos, ALIAS=THER, USAGE=I08, ACTUAL=A08,
      MISSING=ON, $

The following procedure creates the table GGDB2 based on the FOCUS data source GGSALES (with MISSING=ON attributes added to the DOLLARS field in the Master File):

FILEDEF GGFLAT DISK USER1.GGFLAT.DATA SHR REU 
SET HOLDMISS = ON
SET HOLDLIST=PRINTONLY
SET ASNAMES = ON
TABLE FILE GGSALES
SUM DOLLARS AS '' 
BY CATEGORY
ACROSS PRODUCT
WHERE PRODUCT NE 'Coffee Grinder' OR 'Coffee Pot'
ON TABLE HOLD AS GGFLAT FORMAT ALPHA
END
 
CREATE FILE GGDB2 DROP
MODIFY FILE GGDB2
FIXFORM FROM GGFLAT
DATA ON GGFLAT
END

The following TABLE request calls the SQL function COALESCE:

SET TRACEUSER = ON
SET TRACESTAMP = OFF
SET TRACEON = STMTRACE//CLIENT
 
DEFINE FILE GGDB2
VALUE/I8 MISSING ON = SQL.COALESCE(Biscotti, Capuccino, Croissant, Espresso, Latte);
END
TABLE FILE GGDB2
PRINT Biscotti Capuccino Croissant Espresso Latte VALUE
BY CATEGORY
ON TABLE SET PAGE NOPAGE
END

The trace output shows that the SQL function call was passed to the RDBMS:

 SELECT
COALESCE(T1."BIS", T1."CAP", T1."CROI", T1."ESP", T1."LAT"),
T1."CAT",
T1."BIS",
T1."CAP",
T1."CROI",
T1."ESP",
T1."LAT"
 FROM
PMSSAE."GGDB2" T1
 ORDER BY
T1."CAT"
 FOR FETCH ONLY;

The output is:

CATEGORY     Biscotti  Capuccino  Croissant  Espresso     Latte     VALUE
--------     --------  ---------  ---------  --------     -----     -----
Coffee              .    2401556          .   3906243  11000388   2401556
Food          5387773          .    7758857         .         .   5387773
Gifts               .          .          .         .         .         .

Information Builders