Database Interface Designer: Websphere Transformation Extender
Database Interface Designer: Websphere Transformation Extender
Database Interface Designer: Websphere Transformation Extender
October 2006
This edition of this document applies to WebSphere Transformation Extender, 8.1 and to all subsequent releases and
modifications until otherwise indicated in new editions.
To send us your comments about this document, e-mail DTX_doc_feedback@us.ibm.com. We look forward to
hearing from you.
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any
way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 2006. All rights reserved.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
Chapter 1. Database Interface Designer overview . . . . . . . . . . . . . . . . . . 1
Basic steps for using database data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
To use the Database Interface Designer to import database definitions . . . . . . . . . . . . . . . 1
To use the Map Designer to configure database sources, targets, or operands in a rule . . . . . . . . . . 2
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Programming interface information . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Trademarks and service marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Contents v
vi WebSphere Transformation Extender: Database Interface Designer
Chapter 1. Database Interface Designer overview
The Database Interface Designer is used to import metadata about queries, tables,
and stored procedures for data stored in relational databases. It is also used to
identify characteristics of those objects to meet mapping and execution
requirements such as update keys and database triggers.
After defining database queries or tables in the Database Interface Designer, define
your map in the Map Designer where, in map cards, you can specify an input
source as either a query or a stored procedure and an output target as either a
table or a stored procedure.
The adapters provide the option of using a driver to connect to the platform of
your choice so that you can automatically create type trees for database queries
and tables. The adapters also provide a test environment on the PC for maps using
data stored in a database.
You can also install adapters on additional systems to provide remote database
connectivity, such as with ODBC, Oracle, Sybase, or DB2, on operating systems
such as HP-UX, Sun Solaris, AIX, and so on.
Non-Windows adapters do not require the Database Interface Designer if you plan
to only use mtsmaker without a database/query file (MDQ) to generate each type
tree. For information about using mtsmaker, see the Resource Adapters
documentation.
When the Database Interface Designer runs, the Startup dialog appears. In this
dialog, you can select how the Database Interface Designer program should open.
The following options are available:
v Open an existing database/query file
Browse for the MDQ file you want.
v Create a new database/query file
Create a new MDQ file.
v Open a recently used database/query file
Select one or more files from the displayed file list. You can also double-click on
a file from this list to open it.
The Startup dialog can be disabled by enabling the Do not show this at startup
check box; however, you can always access this dialog from the Database Interface
Designer window Help menu by selecting the Startup Window menu option.
When you create a database/query file in the Database Interface Designer, a file
named Database_Query File (which is the default file name) followed by an
assigned, sequential number appears in the Navigator. This indicates that you can
begin defining databases, queries, and so on. Save this database/query file (a file
name with an MDQ extension), providing an appropriate name and location.
The Navigator
The Navigator graphically presents all of your opened MDQ files and the
databases that they contain. It also provides a graphical representation of the
queries, stored procedures, message queues, and tables or views that have type
trees generated. Also displayed are tables and views with update keys defined, as
well as variables that are defined in each MDQ file.
This procedure assumes that the Navigator is floating in the main window.
1. In the Navigator, right-click anywhere around the border of the window, except
in the title bar.
The context menu appears.
2. If the Allow Docking option is not available, disable the check mark from the
Float In Main Window option.
The Navigator is docked.
or
If the Allow Docking option is available, select it and go to the next step.
3. After selecting Allow Docking, you can toggle between a docked window and
a floating window by double-clicking the top border (below the title bar) of the
Navigator. Double-click the title bar so that the Navigator is again docked.
Menu
The Database Interface Designer window menu provides the common menu
structure for commands generally used with Windows programs, as well as for
commands to accomplish specific Database Interface Designer tasks.
Toolbar
The toolbar is a part of the Database Interface Designer window, providing quick
access to various tools that invoke Database Interface Designer actions while
working with database/query files. The left side of the toolbar provides the tools
generally available in Windows applications. The remaining tools are specific to the
Database Interface Designer. The applicability and behavior of each tool depends
upon the Database Interface Designer object selected and its current state.
File menu
The File menu provides the commands that are generally available in Windows
applications.
View menu
The View menu provides selections to control the appearance of your Database
Interface Designer environment.
Database menu
The Database menu provides commands to initiate actions for a selected database.
Query menu
The Query menu provides commands to initiate actions for a selected query.
Tools menu
The Tools menu provides options to customize your Database Interface Designer
environment.
Help menu
The Help menu offers choices to display information about the Database Interface
Designer.
Chapter 2. Database Interface Designer basics 9
Using the keyboard, press Alt H to view the Help menu.
General options
In the list of options, select General to specify values concerning the backing up
and saving of your MDQ files. The fields in this dialog are as follows:
Field Description
Auto-save files every n minutes (where n represents a number)
This spin button indicates the time interval at which to automatically save
opened MDQ files. The default value is 0.
Show Banner
This check box specifies whether to display the banner, which appears
between the title bar and the menu bar of the Database Interface Designer
window. The default setting is enabled.
Backup on save
This check box specifies whether to create a backup copy of each MDQ file
when the file is saved. The default setting is enabled.
Navigator options
In the list of options, select Navigator to specify how to display objects in the
Navigator. The Navigator options are described in the following table.
Field/Button Description
Select this button to display the Font dialog in which to
Font select the font and font size to be used for text. The
default selection in the Sample list is Arial (10pt).
Tables/views option
In the options list, select Tables/Views to determine the objects to be displayed
that are associated with the database. The fields in this dialog are as follows:
Field Description
List tables
This check box determines whether tables are displayed in the database
list. The default value is enabled.
List views
This check box determines whether views are displayed in the database
list. The default value is enabled.
List synonyms
This check box determines whether database synonyms are displayed in
the database list. The default value is enabled.
Confirmations options
In the list of options, select Confirmations to specify the actions for which you
want a confirmation dialog displayed before completion of those actions.
Field/Button
Description
Database operations
This group box displays the options that control whether confirmation
dialogs are displayed with regard to database operations. Select any or all
of these options.
Deleting database(s)
This check box determines whether a confirmation dialog appears when
deleting a database. The default value is enabled.
Copying database(s)
This check box determines whether a confirmation dialog appears when
copying a database. The default value is enabled.
Shortcut keys
You can assign your own shortcut keys for any existing or new menu items. Using
the Shortcut Keys dialog, you can:
v Assign shortcut keys.
v Remove shortcut key assignments.
v Restore the shortcut key assignments present at installation.
For information about these procedures, see the Design Studio Introduction
documentation.
After starting the Database Interface Designer, the Navigator lists one or more
MDQ files depending upon whether your selection was to create a new MDQ file
or to open one or more existing files.
When an MDQ file is created, it appears in the Navigator next to the appropriate
icon. The Database_QueryFile file name is automatically assigned, along with a
sequential number.
Defining a database
When an MDQ file appears in the Navigator, you can add new database
definitions to it or you can modify the name of an existing database. This is done
using the Database Definition window. Each Database Definition window
contains some settings that are common across all platforms and others that are
platform-specific. To view more information about each platform-specific setting,
refer to either the context-sensitive help available from the dialog itself or to each
platform-specific reference guide.
For the purposes of outlining a basic procedure to define a database, the ODBC
adapter for the Windows platform will be used. An example follows.
Setting Description
This is the name of the database being defined.
Database Name This name appears in the Navigator.
Adapter
Type This is a list of adapters that can host the
database you are defining. Select one from the
list. The default value is ODBC.
Data Source
Database Interface
Designer Both this and the Runtime settings are
platform-specific settings. On other platforms,
you may have different settings. Again, see the
platform-specific adapter reference guide or the
context-sensitive help for more setting-specific
information.
To define a database:
1. From the Navigator, select Databases under the MDQ file.
2. From the Database menu, select New.
or
Right-click the Databases object in the Navigator and select New.
The Database Definition window appears.
3. Enter information for the remaining settings as desired.
4. Click OK.
The new database name appears in the Navigator next to the database icon.
Defining a query
After you have opened an MDQ file in the Database Interface Designer window
and a database has been defined, you can specify queries. To use a query as a
source, define the query by assigning it a name and entering either the SQL
SELECT statement or the stored procedure invocation statement.
To define a query:
1. In the Navigator, select Queries under the database icon for which you want to
add a query.
2. From the Query menu, select New.
The New Query dialog appears.
3. In the Name field, enter a name for your query. Use this name to reference this
query using the Map Designer or you can use it in a data source override
execution command.
4. In the Query text box, enter an SQL statement that defines how data should be
retrieved from the database.
If your SELECT statement includes table names with spaces, you must enclose
them with either single or double quotation marks.
5. Click OK.
The new query appears in the Navigator next to the query icon.
XML Schema
The MDQ files are well-formed, valid XML documents. MDQ files can be created
using the Database Interface Designer (DID) or any other utility capable of creating
XML documents. The XML Schema file that is used by WebSphere Transformation
Extender to validate MDQ files is mdq.xsd.
Note: Do not modify the content of the mdq.xsd file. Unexpected results may
occur if you do.
The following topics contain information related to saving MDQ files from the
Database Interface Designer (regardless of whether they were originally created in
the Database Interface Designer or using another utility):
v ″XML prolog text″
v ″XML data from XML-generated MDQ files″
v ″Attribute formatting″
v ″Password encryption″
v ″Backup copies″
This means that the MDQ files saved from the Database Interface Designer use the
UTF-8 encoding scheme.
Attribute formatting
Attribute values are always enclosed in double quotes.
Password encryption
The XML schema provides two different password elements:
v PASSWORD.literal
v PASSWORD.encrypted
In an MDQ file that has not been saved in the Database Interface Designer, only
the PASSWORD.literal value can be specified, which is not encrypted. When the file
is saved in the Database Interface Designer, the password will be encrypted (using
the PASSWORD.encrypted element).
Backup copies
If the MDQ file was created (and saved) in an earlier version of the DID and when
that file is edited and saved from the DID, this newly saved MDQ file is in the
current version. In addition, a backup copy of the MDQ file is created for the older
version using the ODQ filename extension (instead of MDQ).
Runtime execution
If the -MDQ adapter command is used along with the DBLOOKUP, DBQUERY, GET or PUT
map functions or if it is specified as an adapter command in the database cards,
the MDQ file is parsed at runtime.
Design-time execution
If the MDQ file name is specified in the DatabaseQueryFile setting of a map card,
the MDQ file is parsed when the map is compiled, which is during design time for
the map, not at runtime.
After you have performed a comparison between two MDQ files, color-coding is
used to highlight what is unique between the two:
v Differences are highlighted in red.
v New information is highlighted in blue.
The Database Properties tab in each lower windowpane also appears in red letters.
(If there were no differences, this tab would appear in black letters.)
Query differences
If there are differences between the two compared MDQ files with regard to query
syntax or column overrides, the name of the query with differences appears in red
letters in the Database Differences window. If the query in each MDQ file is
uniquely named, each query name appears in blue letters.
If each MDQ file has a query with the same name, but containing unique
information, the Query and/or Column Overrides tabs in each lower windowpane
appear in red letters. (If there were no differences, these tabs would appear in
black letters and you would only see one display in the bottom pane at a time,
depending upon where your cursor is in the upper pane.) When the tabs are red,
you can go to each display and see the differences indicated in red letters.
Click the Query and Column Overrides tabs in each pane to view the differences.
Variable differences
If the variables of the two compared MDQ files have the same name, but different
settings, the variable name will appear in red letters in the upper pane and both
variables will appear in the bottom panes with the tab letters also in red letters. In
the bottom panes, the unique value(s) will appear in red letters. If the variable
names of either of the two compared MDQ files are different, the name of each
variable appears in blue letters in the Database Differences window. If the variables
are exactly the same, the name of the variable in both the upper and lower pane
and the Variables tab would all appear in black letters.
The columns on this tab (Column Name, Column Length, Presentation, and
Interpret As) correspond to fields and list names in the Column Datatype
Specification dialog.
Table differences
If the tables of the two compared MDQ files have the same name, but different
values for column overrides or update key definitions, the table name will appear
in red letters in the upper pane and both tables will appear in the bottom panes
with the Column Overrides and/or Update Keys tab letters also in red letters. In
the bottom panes, the unique value(s) will appear in red letters. If the table names
of either of the two compared MDQ files are different, the name of each table
appears in blue letters in the Database Differences window. If the tables are exactly
the same, the name of the table in the upper pane and the Column Overrides and
Update Keys tabs and related information would all appear in black letters.
Click the Column Overrides and Update Keys tabs in each pane to view the
differences.
The columns on the Column Overrides tab (Column Name, Column Length,
Presentation, and Interpret As) correspond to fields and list names in the Column
Datatype Specification dialog.
When you generate type trees using the Database Interface Designer, a substitution
value must be entered for each variable to ensure that the syntax of the SQL
statement is valid. The Database Interface Designer provides a facility for
specifying a value for these variables; however, the value you enter for a variable
in the Database Interface Designer does not have to be the same value passed at
runtime. (Any value can be passed.)
Use the Define Variables dialog to enter the variable values. Note that you cannot
generate a type tree for the query until you have specified a value for each variable
it contains. Also, if the variable you are defining in the Define Variables dialog is a
text string, you must enclose the value in single quotation marks.
The pseudo values specified using the Define Variables dialog are used in the
Database Interface Designer only when accessing the database to generate the type
tree. They are not used when executing a map.
To delete a variable
When a variable is removed from a query statement that was previously defined in
the Database Interface Designer, the variable is automatically deleted from the
Navigator and no longer displays.
The correct value for each variable is specified at run time using the Variable
adapter command (-VAR) in the Input Source - Override execution command (-ID).
For more information about how to specify values for these variables at runtime,
see the Resource Adapters documentation.
Generated type trees may differ when generated using different database adapters.
For example, a date field may be represented differently by different databases. For
this reason, use the same adapter type that will be used at run time to generate the
type tree with the Database Interface Designer. Or, if you use ODBC, use the
Column Attributes Override dialog that is described in the Resource Adapters
documentation.
To define the type tree to generate from a table or view, use the Generate Type
Tree from Tables dialog or the Generate Type Tree from Views dialog. The
following table contains fields and descriptions.
Field Description
This is the name of the database from which you want
Database Name to generate a type tree. (This name is automatically
inserted based upon your selection in the Navigator.)
This list displays all of the tables, views, or synonyms
Tables/Views that have been defined in this database. Select one or
more from this list.
Note: If the table, view, or synonym you want is not
displayed in this list, add it by right-clicking in the list,
selecting Insert, and typing the desired name.
File name This field displays a system-generated file name based
upon the database selection in the Navigator. The
default value is the database name with a type tree
extension (MTT) and a default path.
The generated type tree is represented in the Navigator with the table/view icon
next to the name.
An example of the Generate Type Trees from Stored Procedures dialog follows,
along with a table describing its fields and their descriptions.
Field Description
Database Name (Display only) This is the name of the database from
which you want to generate a type tree. (This name is
automatically inserted based upon your selection in the
Navigator.)
Stored Procedures This list displays all of the stored procedures that have
been defined in this database. Select one or more from
this list.
Field Description
Database Name This is the name of the database from which you
want to generate a type tree. (This name is
automatically inserted based upon your selection
in the Navigator.)
Tables/Views This list displays all of the queues that have been
defined in this database. Select one or more from
this list.
Note: Type trees generated from queues are not graphically represented in the
Navigator.
From a query
When generating a type tree from a query, information is used from your database
and from the Database Interface Designer to create the type tree. If you change the
definition of your query in the Database Interface Designer or edit that database
definition, you must generate a new type tree to reflect the new information.
Generating a type tree provides a way to test the syntax of your select statement. If
you can successfully generate a type tree from a query, you know that the query
has valid syntax.
An example of the Generate Type Trees From Query dialog follows, along with a
table describing its fields and their descriptions.
Field Description
File name This field displays a system-generated file name based
upon the database selection in the Navigator. The
default value is the database name with a type tree
extension (.mtt) and a default path.
The generated type tree is represented in the Navigator with the query icon
displayed next to the name.
To print a report:
1. Highlight the database within an MDQ file for which you want to print the
information.
2. From the File menu, select Print.
or
In the Navigator, right-click the icon of the database and select Print.
The Print dialog appears.
3. To print all of the entities displayed, skip to the next step.
or
To select certain entities to not be printed, disable the appropriate check box
next to the entity name.
4. To use the default font for the report, skip to Step 6.
or
To change the font for the report, click Font.
The Font dialog appears.
5. Change the settings as desired and click OK.
The Font dialog is closed and you are returned to the Print dialog.
6. Click OK.
The Print dialog appears.
7. Make any changes as desired and click OK.
The report is printed.
Note: Because this is a toggle command, use the same procedure for both enabling
and disabling trace.
1. In the Navigator, highlight the MDQ file for which you want to enable a trace.
2. From the File menu, select Trace.
Note: If a trace file has not yet been generated, a blank window appears.
3. To define how you want to view multiple trace windows simultaneously, from
the Window menu, enable either Cascade, Tile Horizontally, Tile Vertically or
Arrange Icons.
In addition to the Database Interface Designer trace that is applicable only when
working in the Database Interface Designer environment, you can also generate an
additional database trace file that records activities occurring during map
execution.
Field Description
Find what Enter the text upon which to search. The default
value is blank.
Match whole word only This check box determines whether to use the
value entered in the Find what field to match
only whole words against in the trace file. (For
example, if this was enabled and text was your
find value, texts would not be a match.). The
default value is disabled.
Note: Ensure the trace window containing the desired trace file is the active
window.
or
From the Window menu, select the name of the trace file.
2. From the Edit menu, select Find.
The Find dialog appears.
3. In the Find what field, enter the text you want to find.
4. Make other selections as desired.
5. Click Find Next.
If a match is found, the text is highlighted in the file in the trace window.
Otherwise, there may be a message asking if you want to continue searching.
6. Repeat Step 5 until you have finished your search.
7. Click Cancel.
Although you can manually create a type tree for a table or a query using the Type
Designer, it is not recommended.
The following examples represent type trees generated by the Database Interface
Designer from two queries (one SELECT and one calls a stored procedure), a table,
a stored procedure, and a message queue.
As shown in these examples, the type trees generated from tables, views, queries,
and stored procedures are very similar, while the type tree generated for message
queues differs slightly.
Each type tree generated by the Database Interface Designer or mtsmaker for a
database table or query (or a query that calls a stored procedure) will have the
following standard characteristics:
v The root of the generated type tree is named Data.
v The generated type tree contains a category whose name corresponds to any one
of the following:
– the name of the table in the database
– the name of the query in the MDQ file
– the name specified using the Category Type (-N) parameter for mtsmaker
The types defining the columns and rows returned by the database adapter
stem from this type. In the examples, the categories are ActiveProjects and
stores.
Again, if you use the Database Interface Designer, these conversions are
automatically performed. If you use mtsmaker, you must manually convert these
characters.
The DBSelect or DBTable type is an implied group with a series of row objects as
its only component.
see the following table for information about specifying the value for the Row
group format list when generating a type tree for a query or table.
Using Information
You can specify the syntax for each of these when generating the type tree.
In the Group options pane, which is located in the dialog for generating the type
tree, you can specify the Delimiter, Terminator, and Release setting values to be
used in the type tree. The default values are |, None, <CR><LF>, and !,
respectively. The Initiator value cannot be specified; it is always set to None.
When using the DBLOOKUP, DBQUERY, GET and PUT map functions with the database
adapter, the adapter will use the default values for the Delimiter, Terminator, and
Release settings. This is because the data passed to and from the adapter is, in this
case, not represented by the type trees generated in the Database Interface
Designer. The adapter will use the default values for the Delimiter, Terminator,
and Release settings since it cannot access this information from a type tree.
In the Group options pane, which is located in the dialog for generating the type
tree, you can specify the Terminator setting values to be used in the type tree. The
default value is <CR><LF>.
When using the DBLOOKUP, DBQUERY, GET and PUT map functions with the database
adapter, the adapter will use the default values for the Delimiter, Terminator, and
Release settings. This is because the data passed to and from the adapter is, in this
case, not represented by the type trees generated in the Database Interface
Designer. The adapter will use the default values for the Delimiter, Terminator,
and Release settings since it cannot access this information from a type tree.
Each item is defined according to the data type and length information returned to
the database adapter by the database driver. For more information about the
correspondence between database data types and item formats, see the specific
adapter reference guides.
The minimum size of item types for columns in a delimited Row is 0 unless
otherwise specified by the database driver. The minimum size of item types for
columns in a fixed Row equals the maximum size.
A category called SizedGroup is added to the tree. This category has an item
subtype called Sizeof and group subtypes with the same names as the item types
for each binary column.
The following changes are made to the type tree to account for columns
representing binary data:
v Two variable length binary items are created as subtypes of the Column type to
represent the value of the two binary type columns.
v The Sizeof item is a subtype of the SizedGroup category and is defined as a
character integer item.
v Also, as a subtype of the SizedGroup category, two groups given the same
name as the binary column type are created, each group including two
components. The first component of each group is the Sizeof item; the second,
the variable length binary item (either).
v The formats of those group types defined as subtypes of the SizedGroup
category are defined in the same way as the format for the Row group type.
If the type tree has a delimited Row group format, the group types for the
binary columns are also defined as delimited groups with the pipe character (|)
as an infix delimiter. In this example, the Sizeof component is defined as being
required in the component list. However, the binary item type is optional (with a
range of 0:1).
You cannot generate a fixed Row group format type tree for a table or query
containing variable length binary data.
If the type tree has a fixed Row group format, the group types for the binary
columns are also defined as fixed groups. In this situation, both the Sizeof
component and the binary item type are required.
v In the group type component list, the Sizeof component has the Sized attribute,
indicating that the Sizeof item contains the size of the binary item that follows
it.
For example, the type tree generated for the following query
SELECT MIN(salary), MAX(salary) FROM Employee
would have a Row with two columns representing the result of the SQL MIN and
MAX functions. In the type tree, the items created to represent the results of these
functions would be Expr1000 and Expr1001 for the MIN and MAX functions,
respectively.
which would result in a type tree containing a Row with two columns
representing the result of the SQL MIN and MAX functions. In the type tree, the
items created to represent the results of these functions would be min_salary and
max_salary. An example of this follows.
You can also use the AS keyword to specify an alias for a column having a name
containing any of the characters that are invalid in a type name. Or, you can
specify an alias for a column having a name longer than 32 characters (which is
the limit for the size of a type name).
The following example results in a type tree having a Row with three columns.
Select SomeReallyReallyReallyLongColumnName AS
SomeLongColumnName,
1st-Payment AS Payment#1,
2nd-Payment AS Payment#2
from some_table
Note: You can use either a standard SQL SELECT query or a query using a stored
procedure. For specific information about using stored procedures, refer to
″Using stored procedures.″
After you have defined the query and have generated the type tree, using a
database as an input is very similar to using a file as input.
Using the Map Designer, specify Database as the GET → Source setting in the
input card and supply the name of the MDQ file containing the definition of the
database and query you want to use. see the following procedure and example.
Note: For more information about the map settings in this procedure, see the Map
Designer documentation. This procedure specifically addresses
database-specific parameters and settings.
1. In the Map Designer, when defining the settings for SourceRule, select
Database as the GET → Source setting.
The settings displayed in the Input Card dialog change to display the database
adapter settings for a source.
2. From the Card menu, select New.
The Add Input Card dialog appears.
3. For the CardName setting, enter a name for the card that describes the data
object represented by this card.
© Copyright IBM Corp. 2006 43
4. For the TypeTree setting, select the type tree containing the group type that
defines the desired query.
5. For the TypeName setting, select the group type from the type tree that defines
the desired query (for example, DBSelect).
6. For the TypeName setting, select the group type from the type tree that defines
the desired query (for example, DBSelect).
7. Specify the FetchAs, WorkArea, FetchUnit, and all Backup settings as desired.
For detailed information about these settings, see the Map Designer
documentation. For database adapter-specific information about source settings,
see the adapter-specific reference guide.
8. For the GET → Source setting, select Database from the list.
The SourceRule settings change to display the database adapter settings.
9. Specify the values as desired in the adapter settings and click OK.
Use the Map Designer to specify Database as the PUT → Target setting in the
output card at the executable map level. Provide the name of the MDQ file
containing the definition of the database, along with the table, view, message
queue, or stored procedure to be used.
Note: For more information about the map settings in this procedure, see the Map
Designer documentation. This procedure specifically addresses
database-specific parameters and settings.
1. In the Map Designer, select the To window.
2. From the Card menu, select New.
The Add Output Card dialog is displayed, an example of which follows.
3. For the CardName setting, enter a name for the card.
4. For the TypeTree setting, select the type tree file containing the group type that
defines the content of the desired output.
5. For the TypeName setting, select the group type from the type tree that defines
the desired output (for example, DBSelect).
6. Specify all Backup settings as desired. For detailed information about these
settings, see the Map Designer documentation.
7. For the PUT → Target setting, select Database from the list.
The settings displayed in the Output Card dialog change to display the
database adapter settings for a target.
For database adapter-specific information about target settings, see the
adapter-specific reference guide.
8. Specify the values as desired in the adapter settings and click OK.
There is one restriction for Scope. If the value of the SourceRule → FetchAs setting
in an input card is set to Burst, the Scope setting is always Map. The adapter
scope is determined to be Map because the context of the SELECT statement
cannot be maintained after the transaction has been terminated through a commit
or rollback. Therefore, if Burst is the value for the SourceRule → FetchAs setting in
an input card, any value in the Scope setting as well as any adapter command
(-CCARD or -CSTMT) specified in the GET> Source → Command setting is ignored.
When connection sharing occurs between cards and maps within a map, the
connection is described as active as long as there are one or more cards or rules
that access a database and that have yet to be committed or rolled back. (For
example, an active transaction exists.) When there are no such cards or rules, the
connection is inactive, yet still alive.
When using a DBLOOKUP, DBQUERY, GET or PUT function, the Transaction → Scope
setting defaults to Map when the map SourceRule → FetchAs setting is set to
Integral. The Transaction → Scope setting will change to Burst when the map
SourceRule → FetchAs setting is set to Burst; the Transaction → OnFailure setting is
always Rollback.
Connection factors
The factors determining whether a connection is reused are the following:
v the database type
v the connection string (if applicable), datasource, or database name
v the user ID
v the OnFailure setting (Commit or Rollback)
v the Transaction → Scope setting
v the SourceRule → FetchAs setting
v whether -CCARD or -CSTMT are specified within the adapter’s command
Connection rules
Existing connections are reused whenever possible while adhering to certain
connection rules. The rules are as follows:
v An inactive connection is reused if the database type, connection string, and user
ID of the new card or rule match those of the previous card or rule that had
established the connection.
v In addition to the database type, connection string and user ID, an active
connection is reused only if the OnFailure and Transaction → Scope settings
match in the previous card or rule and the new card or rule.
v If a card or rule has -CSTMT set within the adapter’s command, this connection
may be shared with any other card or rule that has -CSTMT set or that has an
Transaction → Scope setting of Card (or -CCARD within the adapter’s command).
v If Burst is the SourceRule → FetchAs setting for an active card, it (the card) is
always executed in its own transaction. It establishes a connection that cannot be
shared by any other card for the duration of the map.
Connection example
A map has four database input cards. Assume the connections specified
(datasource, userID, and so on) are the same for each.
In this example,
v A connection will be made and a transaction started for Card 1.
v Because Card 2 has Transaction → Scope set to Card, this initial connection
cannot be shared. Therefore, another connection will be made for this card.
v For Card 3, because its OnFailure setting differs from the setting for Card 1, the
connection established in Card 1 cannot be reused. However, the connection
established for Card 2 is inactive (because Transaction → Scope was set to Card
and the card has completed) and, therefore, will be reused for Card 3. A new
transaction is started on this existing connection.
v Card 4 is able to share the connection established by Card 1 and can be part of
the same transaction because all of its settings match.
If the map fails, the transaction containing both Card 1 and Card 4 will be rolled
back and the transaction for Card 3 will be committed.
The term key in this usage does not necessarily mean that the column is part of a
database primary or foreign key.
For any update to be performed, update mode must be specified for the target.
This is accomplished by specifying the Update adapter command (-UPDATE) in the
PUT → Target → Command settings using the Map Designer or Integration Flow
Designer, or by passing it with the override execution command on the command
line at execution time. For more information about how to enable update mode,
refer to ″Specifying update mode″ .
A generated type tree with specified update keys is represented in the Navigator
under Tables.
You must specify -UPDATE in the PUT → Target → Command setting so that your
specified columns are automatically updated.
Note: You can override the behavior defined in the Database Interface Designer
by using the command line to specify the appropriate database adapter
commands for the database adapter. For information about the
database-specific adapter commands, see the Resource Adapters
documentation.
v If more than one column is designated as a key column, the values generated by
a map must match the values in each designated key column for the row to be
updated.
v If your map generates a row with key column values that match more than one
existing record, all of the matching records in the columns you have specified as
update columns are updated with the new row values.
In the following example, a table (PersonalInfo) has the following key columns
and update columns defined in the Database Interface Designer.
When this map runs, because -UPDATE is enabled for the output, the database
adapter will first go through the results of the map and update all rows in the
table matching the key columns in the output produced. Essentially, the following
SQL statements are executed:
UPDATE PersonalInfo
SET FirstName=’Karl’, LastName=’March’, PhoneNumber=’(847)
555-1234’
WHERE ID = 10
UPDATE PersonalInfo
SET FirstName=’Janice’, LastName=’Armstrong’,
PhoneNumber=’(203) 555-9898’
WHERE ID=14
In the first UPDATE statement, because this statement does not find any rows to
update, the following SQL statement is executed.
INSERT INTO PersonalInfo VALUES (10,’Karl’, ’March’,
’(847) 555-1234’, ’999-88-7766’)
This execution creates a new row in the table for Karl March-including values for
the ID, FirstName, LastName, PhoneNumber, and SSN columns.
In the second UPDATE statement, because an existing row has an ID value of 14,
only the values of the FirstName, LastName, and PhoneNumber columns are
updated because of the settings specified in the Columns to update list in the Set
Table Update Key Columns dialog of the Database Interface Designer. In this
example, Janice Taylor’s last name changed to Armstrong and her telephone
number is changed to (203) 555-9898. Her social security number remains
unchanged because it is not a column that has been designated for update.
However, there are certain situations in which you might not want to define the
entire query as a data source or the table as a target. For example, you may have a
very large table that is used as a source for cross-reference in your map. However,
because of its size, reading in and validating all of the information as an input card
is impractical. In other situations, you may want to call one map from another
using the RUN function when one of the data sources is a dynamically built query.
Two functions provide the ability to access database information from within a
rule:DBLOOKUP and DBQUERY. The difference between the two functions is subtle and
is based upon how the data resulting from either function is returned.
Both functions return the results of a query (SQL SELECT statement) in the same
format as a query specified for a map input card, using the delimited row format.
However, the DBLOOKUP function strips off the last carriage return/line feed.
Because this information is stripped, it is easier to make use of a single value
extracted from a database.
DBLOOKUP and DBQUERY execute an SQL statement within a rule against the database.
The SQL statement can be any statement permitted by your database management
system or database-specific driver.
There are two syntax methods that can be used to specify the arguments for these
two functions: Syntax1 and Syntax2.
If column data from a table or database varies because it may be based upon a
parameter file, use Syntax2. For more information, refer to ″Syntax2 - using
dynamic adapter commands″ .
Using this syntax, DBLOOKUP and DBQUERY use the following arguments.
Note: The MDQ file is accessed at map build time and is not needed at
runtime.
database_name
Name of a database in the MDQ file as defined in the Database Interface
Designer.
Note: This name is case-sensitive and must exactly match the name as
defined in the Database Interface Designer.
adapter_commands
Name of an adapter command or commands. This name is an optional
argument that appears after database_name, which allows you to specify
database adapter commands in component rules in the Type Designer and
map rules in the Map Designer.
Using this syntax and the Syntax 2 formatting issues (″Syntax2 formatting issues″ ),
DBLOOKUP and DBQUERY use the following arguments.
Argument
Explanation
SQL_statement
single_text_expression
adapter_commands
Either
-MDQ mdq_file -DBNAME db_nameor
-DBTYPE database_type [database_adapter_commands]
Examples
The section presents different DBLOOKUP and DBQUERY examples.
PART_NUMBER PART_NAME
1 1/4″ x 3″ Bolt
2 1/4″ x 4″ Bolt
Also assume that this database has been defined in a file named mytest.mdq using
the Database Interface Designer. The name of the database, as specified in the
MDQ file, is PartsDB. Notice the difference between the returned values from the
execution of the following two Syntax1-formatted functions.
Using Syntax2, you can also specify the DBLOOKUP or DBQUERY functions as in the
following examples.
DBLOOKUP("SELECT PART_NAME from PARTS where PART_NUMBER =1",
"-MDQ mytest.mdq -DBNAME PartsDB")
DBQUERY("SELECT PART_NAME from PARTS where PART_NUMBER =1",
"-MDQ mytest.mdq -DBNAME PartsDB")
Note that both the MDQ file name and database name are specified.
PART_NUMBER PART_NAME
1 1/4″ x 3″ Bolt
2 1/4″ x 4″ Bolt
Also assume that this database has been defined in a file named mytest.mdq using
the Database Interface Designer. The name of the database, as specified in the
MDQ file, is PartsDB.
returns:
1|1/4" x 3" Bolt<cr/lf>2|1/4" x 4" Bolt<cr/lf>
Notice that if the same function was executed using DBLOOKUP, the results would
be:
1|1/4" x 3" Bolt<cr/lf>2|1/4" x 4" Bolt
The difference between the two results is that the final carriage return/line feed is
stripped off the end of the results of the DBLOOKUP function.
Using Syntax2, you can obtain the same results as in the previous DBQUERY function
as shown in the following examples:
DBQUERY ("SELECT * from PARTS where PART_NUMBER =1",
"-MDQ mytest.mdq -DBNAME PartsDB")
or:
DBQUERY ("SELECT * from PARTS where PART_NUMBER =1",
"-DBTYPE ORACLE -CONNECT MyDatabase -USER janes
-PASSWORD secretpw")
For example, assume you need to create a map that processes inventory requests,
one order at a time, using a messaging system. Within the transformation of your
data, you need to reference the item master table that contains hundreds of
thousands of rows. However, for each item within the inventory request, you need
to get the internal item number, vendor ID, and description column value. You can
select from several available options, such as:
v Use a database source.
Define a query for only those columns needed. Use this for a database source
that you can then use within a LOOKUP, EXTRACT, or SEARCHUP/SEARCHDOWN
function. However, due to the size of the item master table, this might mean
validating hundreds of thousands of rows to find the item information for only
a few items.
v Use multiple DBLOOKUP functions.
Assuming that the internal item number, vendor ID, and description column
values are going to be used within different outputs, you could use three
separate DBLOOKUP functions to get the appropriate column value for each item.
However, this means executing three SQL statements to access the same row
within the item master table.
v Use the DBLOOKUP and WORD functions.
Assuming that a functional map will be used to build an object containing the
three desired columns, a DBLOOKUP could be used as an argument to the
functional map that retrieves the desired column values. see the following
example:
=F_MakeOne ( Item Set:SomeInput ,
DBLOOKUP ( "SELECT INT_ITEM_NO, VENDOR, ITEM_DESC " +
"FROM ITEM_MASTER WHERE ITEM_NO = ’" +
CatalogID:.:SomeInput + "’" , "PRODXL.MDQ"
"WDDM" ) )
The functional map F_MakeOne has two inputs: an Item Set and a text item (that
is the result of the DBLOOKUP function). The text item will contain the three column
values separated by the pipe character (|). An example follows:
ARQJ06X6|DFQCO|6’ Jump Rope
Then, each rule requiring one of these pieces of data will use the WORD function to
access the appropriate column’s data. For example, if the input card for the results
of the DBLOOKUP function was called ItemData, the rule using the vendor ID
column would be:
=WORD ( ItemData , "|" , 2 )
In the DBQUERY example above, the PART_NAME column value in the row that
contains the PART_NUMBER column value of 1 will be retrieved from the PARTS table.
The PARTS table is in the PartsDB Oracle database specified in the mytest.mdq file,
which was produced by the Database Interface Designer.
This example uses optional database-specific adapter commands. The Trace (-T)
adapter command will produce a database trace file. The Commit by Statement
(-CS) adapter command will commit or rollback the transaction after the rule
executes.
Uses
When you might want to use DBLOOKUP to execute an SQL statement:
v To retrieve a single column value from a database based upon another value in
your data without the carriage return/line feed row terminator
When the Database Management System (DBMS) receives an SQL request, the
request is cached because many applications repeatedly issue the same SQL
statement. If the SQL statement differs from one that the DBMS has recently
processed, the statement is reevaluated. (The DBMS performs parsing, derives an
execution plan, and so on.)
Use the bind facility for DBLOOKUP and DBQUERY functions to submit such statements
to the DBMS so that the statements are syntactically identical. By binding a value
to a placeholder in the SQL statement, the actual syntax of the statement can be
made static.
The syntax for specifying a value in the SQL statement as a bind value is:
:bind( value )
For example, to use a bind variable in the statement above, the SQL statement
would be:
SELECT * FROM MyTable WHERE CorrelationID=:bind(123)
The database adapter strips out the :bind keyword and binds the value 123 to a
placeholder in the statement.
The value in the parentheses is always a text item. Single quotation marks should
not be specified around string literals. For example, if you had the statement:
SELECT Artist FROM CDList WHERE Title = ’Goodbye’
and you want to bind the value for the title, the syntax would be:
SELECT Artist FROM CDList WHERE Title=:bind(Goodbye)
Within the context of a DBLOOKUP or DBQUERY function, the elements of the statement
to be bound are dynamic elements. For example, if the following call toDBLOOKUP is
in a map:
DBLOOKUP ("SELECT Name FROM MyTable WHERE ID="+ Item1:Row +
"and CorrelationID= ’" + Item2:Row + """,
"DB.mdq",
"MyDB")
There is no performance benefit unless all values that change from one invocation
of the statement to the next are bound. For example, if the ID value is bound and
not the CorrelationID value, the statement will vary because the CorrelationID
value varies.
For information about the availability and usage of calling stored procedures,
including the correct native syntax for these calls, refer to each database-specific
adapter reference guide.
In addition to the above methods, when using Oracle object types as parameters in
stored procedures, there is a special syntax that must be used. For more
information about this, see ″Stored Procedures with Object Type Parameters″ .
Option Description
?= Indicates that the return value from a stored function
should be returned
procedure_name The name of the stored procedure or function
argument_list A comma-separated list of arguments in which each
argument is one of the following:
value This is the value to be passed to an
input parameter. If the value
contains spaces, it must be
surrounded by single quotation
marks (for example, ’city of’).
The quotation mark characters are
not passed as part of the
parameter.
If EmpID has a value of SM01930 and Salary has a value of 42,750, the call syntax
would expand to:
call DoSalaryIncrease (SM01930, ?, ?/42750, ?)
The output from this call is a single text item in which each field is delimited by
the pipe character (|). In this example, there will be three fields in the output-one
for each question mark character (?) placeholder. If you do not want to use all of
the output parameters, you can use any other character in place of the question
mark character. For example, if you did not use the EffectiveDate (parm4), the call
could be changed to:
DBLOOKUP
("call DoSalaryIncrease ("+ EmpID:.:PayrollFile
+ ",?,?/" + Salary:.:PayrollFile + ",X)",
"AdminDb.mdq", "HR_DB")
Once again, if EmpID has a value of SM01930 and Salary has a value of 42,750,
the call syntax would expand to:
call DoSalaryIncrease (SM01930, ?, ?/42750, X)
After the stored procedure call is entered in the New Query dialog or the
Edit/View Query dialog (if you are editing an existing query), you can generate a
type tree for the stored procedure.
Generated type trees for stored procedures adhere to the same format as type trees
for queries and will contain a Row group, the components of which correspond to
the ? placeholders in the CALL statement. Return values from stored functions will
typically have the field name RETURN_VALUE unless the database returns a
specific name.
The call syntax for a stored procedure can be used effectively in input cards in
combination with substitution variables to provide values to input parameters. For
example, to call GetPaymentInfo in an input card, because GetPaymentInfo takes
a single input parameter, first define the text in the Query field.
Next, provide the value on the command line for parm1 at execution time as
follows:
dtx MyMap.mmc -ID1 ’-VAR parm1=2000-03-11’
For example, to call a stored procedure by means of ODBC using the native
syntax, the query text you enter in the New Query or Edit/View Query dialog
might be:
{call MyProc(-1)}
The query text for a call to a stored procedure must be in the native database
syntax. For more information about the correct syntax of the procedure call using
your particular database adapter, see the database-specific adapter reference guide.
When you use a stored procedure to define a query, follow the same steps as when
you use a SELECT or other statement:
1. Define the query in the New Query or Edit/View Query dialog of the Database
Interface Designer.
2. Generate a type tree from the query.
3. In the Map Designer, specify the query when defining the data source for the
executable map input card for the stored procedure.
The values for each parameter are passed to the stored procedure with the stored
procedure being called for each row of data.
The types of the parameters may be IN, OUT, or IN/OUT. However, there is no
mechanism to return values from output parameters. Any values passed to an
OUT parameter will be ignored.
Similarly, invoking stored procedures with object type parameters using the ’call’
syntax is possible. For output parameters, there is no special syntax required.
Using a question mark character (?) will result in the entire object being returned
from the stored procedure call. However, for input parameters, a special syntax is
required to specify the objects. The syntax rules are as follows:
v The object must be contained within square brackets. An example of this is:
″[.......]″
v Each element of the type is separated from other elements of the type by the
pipe (|) delimiter character.
v Spaces are not allowed unless they are contained within the data itself.
see the following example. The type ’outer’ is defined by the following ’create
type’ statements:
create type inner as object (
a_char varchar(10),
b_int number(10,0));
create type outer as object (
x_inner inner,
y_date date);
For information about the availability and usage of triggering for your specific
database and platform, see the database-specific adapter reference guide.
Database support
The event(s) that occur causing a trigger to run a map may be the result of a map
or some other application.
The Database Interface Designer allows two different triggering actions during
event-based map execution:
v Table-based triggering
v Row-based triggering
– Column-based triggering (an enhancement to row-based)
Installation requirements
Before you can take advantage of the database triggering functionality, either one
of three database-specific installation scripts must be run by a system
administrator:
Executing the respective script installs the database objects required for database
triggering:
v tables that track ″watch″ events
Four tables are added to your database. These are required for the triggering
functionality. For more information about these tables, refer to ″Tables created
for triggering″ .
v stored procedures that interface to the tables
v (for Microsoft SQL Server only) extended stored procedures that contain
signaling logic
v (for Oracle only) public synonyms for tables and stored procedures
v (for Oracle only) sequences that generate unique trigger IDs
Certain privileges must be granted to the user running the database card
triggers. The specific details for this and additional information are presented at
the beginning of each script.
Column-based triggering
To use column-based triggering (for Oracle only), run either of the following
scripts:
Script Use
m4ora_col.sql
if you are upgrading from a release prior to WebSphere Transformation
Extender 8.0, and had been using Oracle database triggering
m4ora.sql
to re-install the database objects required for column-based triggering
The database triggers will continue to monitor for events while the Launcher is
shut down, thus enabling the system to be fault-tolerant with respect to any
database changes that occur during an unexpected downtime. This fault-tolerant
behavior requires that a normal system shutdown eventually take place. Otherwise,
the database triggers will continually remain in operation, taking up processing
and space resources on the target DBMS.
Make sure you only delete those rows in the Trigger_Events table associated with
the truncated table. Also, you can perform this procedure after dropping and
recreating a table.
Table-based triggering
A typical usage for table-based triggering would be to set up a trigger that will
execute a map to run after another map has completed processing and has inserted
rows into a table.
For information about the Source → Transaction → Scope setting, see ″Database
sources and targets.″ For information about using the Commit by Statement
adapter command (-CSTMT), see the Resource Adapters documentation.
To see how to construct the WHEN expression for table-based triggering, see the
example in ″Table column format″.
Row-based triggering
The row-based triggering design enables a fault-tolerant, multi-server-aware
triggering mechanism that can enable maps to selectively process those rows
associated with a triggered watch event. In the preceding sentence, fault-tolerant
means that data is not lost if a process fails, a connection is dropped, an Launcher
stops, or some other unforeseen interruption occurs. Multi-server-aware means that
Launchers on different machines can connect to and ″watch″ the same table.
The main difference between row-based and table-based triggering is that with
row-based triggering, the query executes on only those rows that have been
updated or inserted, not on the entire table. Additionally, batch-like processing is
possible if the When clause is used to control the time and/or date at/upon which
processing should occur.
To see how to construct the WHEN expression for row-based triggering, refer to
the example in ″SELECT 1 FROM Format″.
Column-based triggering
An enhancement to the row-based triggering functionality is column-based
triggering. It enables you to trigger an event to occur on a row when a particular
column condition is met. This functionality is available in both the m4ora.sql and
Refer to Oracle documentation for the WHEN clause syntax when using it in a
trigger definition.
For information on installing the m4ora.sql and the m4ora_col.sql scripts, refer to
″Installation Requirements″ .
To see how to construct the WHEN expression for column-based triggering, see the
example in the Format of the When Expression section.
To define a trigger:
1. Use the Database Interface Designer to create an MDQ file containing the
desired query.
2. From the Trigger Specification dialog in the Database Interface Designer, define
the conditions under which changes in database tables will trigger a map. The
trigger you define is associated with a query and is saved in the MDQ file. For
more information about this, refer to ″Defining a trigger for a query″ .
3. Use the Map Designer to create an executable map with an input card that uses
the MDQ file containing the trigger specification. For more information, see the
Map Designer documentation.
Defining events
Use the Trigger Specification dialog to define a trigger specification for an
individual query that will be stored with the query in the MDQ file. As you add
and remove the table names, the lists on the right display the tables for which an
Insert into, Delete from, or Update of event comprises the condition(s) that must
be met for the trigger specification. Additionally, you can specify whether
row-based triggering will be used. The different classes of events that you can
specify are:
v Insert into
The insertion of rows into the specified table serves as an input event trigger to
the map that uses this query as a data source.
v Delete from
The deletion of rows from the specified table serves as an input event trigger to
the map that uses this query as a data source.
For example, if you defined events in all three event classes, the implied condition
to be met for the trigger specification would be:
Insert into TableA
OR
Delete from TableB
OR
Update of TableC
When all events have occurred within only one of the specified event classes, the
condition(s) has/have been met for the trigger specification and the map is run.
Specifying AND or OR
Within the Insert into and Delete from event classes, you can define multiple
insert and delete events by specifying multiple tables. Similarly, you can define
multiple Update of events by specifying multiple table names.
Using the Delete from event class disables row-based triggering. However, you
can still define multiple Insert Into and Update of events using row-based
triggering.
When you specify multiple table names within an event class, you must also
specify how you want the condition within the event class to be met-either when
all of the events occur for all of the specified tables or when one event occurs on
any one entry in the list.
The options that dictate the condition(s) to be met when you set up multiple
events are:
Option Description
AND This option dictates that all of the specified events must occur (for
example, TableA AND TableB) for the condition to be met.
OR This option dictates that conditions are met when at least one event occurs
(for example, TableA OR TableB).
Specifying when
After specifying at least one Insert into, Delete from, or Update of event, you can
create an expression that must evaluate to true to satisfy the conditions of the
trigger specification. Enter an expression in the When field that will be evaluated
after the other events have occurred. If the When expression evaluates to true, the
conditions of the trigger specification are met and the map is run. If the When
expression is not true, the state is restored to what it was prior to the occurrence of
any events. When row-based triggering is used, all of the changed rows will be
batched together for subsequent processing after the event is re-triggered and the
When clause has been satisfied.
The When expression in the Trigger Specification dialog can contain any SQL
expressions that are valid for the database. If database columns are referenced in
the expression, the column name must be qualified with the tablename and the
tablename.column_name enclosed in square brackets ([ ]).
For example, if a map should be triggered only when there is a row in the
MyTable table having a column entitled Status with a value of Ready, specify the
Insert into, Delete from, and Update of events and enter the following expression
in the When field:
[MyTable.Status] = ’Ready’
The When expression can support any valid SQL statement that begins with a
SELECT 1 FROM clause. After a database event is detected on the DBMS, the
entire statement (as it appears in the Trigger Specification dialog) is executed.
For example, if a database input card should be triggered for execution only
during a certain time of day, the following statement could be entered:
Note: This example only applies to versions of the Oracle DBMS supported in this
release.
select 1 from dual where
TO_CHAR(SYSDATE, ’HH24’) > ’00’ AND
TO_CHAR(SYSDATE, ’HH24’) < ’06’
This When clause would restrict processing of any database ″watch″ events to the
timeframe of between midnight and 6AM.
An example of the syntax of the column condition that you would specify in the
Trigger Specification dialog of the Database Interface Designer is presented below:
column condition new.part_number = `S’
For more information about using the command line and specifying the Trigger
adapter command (-TR), see the Resource Adapters documentation.
Troubleshooting tools
If you receive an error while attempting to generate a type tree in the Database
Interface Designer or if you run a map that uses database sources and/or targets
and receive a runtime error or do not get the expected output, use any or all of the
following troubleshooting tools:
v Map audit log (map_name.log)
For information about the map audit log and related settings, see the Map
Designer documentation.
v Database Interface Designer trace (mdq_file_name.dbl)
v Database execution trace file (map_name.dbl)
v Database source and target data
v Database audit file (audit.dbl)
v DBMS trace utilities and SQL command tools
Most problems encountered in the Database Interface Designer are relayed to the
user in message dialogs. For example, if an incorrect user-ID or password is
specified for a database, a dialog appears when attempting to generate type trees
for tables in that database. The following example dialog reports an Oracle error
ORA-01017 with the following message as returned by the database driver to the
database adapter:
invalid username/password; logon denied
The following is a sample of a database trace file when generating a type tree that
describes two tables in an Oracle database.
The following example was received when attempting to run a map to retrieve
data from a table in an SQL Server database.
<1324-3020>: Validating the adapter command...
<1324-3020>: Database type is MS SQL Server 7
<1324-472>: Connecting...
<1324-472>: Datalink: MY_2000_SERVER\\test
<1324-472>: UserId : test
indicate the OLE DB provider-specific error code and the corresponding error
description. The last line (beginning with Returned status:) indicates the error
code returned by the adapter that caused the map to fail.
This information can be used, along with the SQL Server documentation, to resolve
the problem. In this particular example, the error was caused by typing the
incorrect server name in the SQL Server Server settings in the Database Definition
dialog, rather than by selecting the name from the list of servers. In this example,
the server name was incorrectly entered as MY_2000_SERVER, instead of its actual
name (MY_2000_SRVR).
To produce the database trace file when using the DBQUERY or DBLOOKUP functions,
use the Syntax2 format to call the function. For example, if output card 3 contains
a DBLOOKUP function, call the function as
DBLOOKUP ( "SELECT ...", "-DBTYPE DB2 -SOURCE LAMBIN
-USER ARL97IN -TRACE").
Use the Trace adapter command (-TRACE) for as many database source or targets as
desired. Note that the information for later cards is appended to the default
database trace file unless a file name is specified using the -TRACE filename option
as described in the Resource Adapters documentation.
The key information in the database trace is in the line defining the query
(beginning withQuery) and the four lines beginning with the Error in: line. In this
example, the attempt to execute the query failed because the table specified in the
query listed does not exist. This would result in a map return code of 12 and a
message of:
Source not available
Upon receiving this error, verify that the query is correct and that the table
referenced in the query exists using the Database Interface Designer or the SQL
command tool provided with your database.
The Update adapter command (-UPDATE) specifies that the rows produced by the
map should update existing rows or should insert new rows, based upon the
update keys configured for the table in the Database Interface Designer. The Trace
adapter command (-TRACE) generates the database trace information for this output
card.
An example of the database trace information produced for this map follows.
This sample database trace file (map_name.dbl) reveals important information that
is highlighted in bold type above and some of which is described below.
v After the logon information in the sample, a message indicates that Update mode
is on. This will affect how the rows produced are handled. Because update
mode is on (enabled by the -UPDATE adapter command), rows in the table are
inserted or updated based upon the update keys defined in the Database
Interface Designer.
v After the connection is made, the database trace shows the column definitions
for the output table.
v Next, the database trace file displays the actual SQL statements to be executed
using the data produced for the output card. Because update mode is enabled,
the database trace file displays both an INSERT statement and an UPDATE
statement. The UPDATE statement is executed for each row in the output for
which a corresponding row is found in the database table, using the update key
defined (which, in this example, is the MemberID column). The INSERT
statement is executed for all rows in the output for which a corresponding row
does not exist in the table.
In this example, the bold text is information that can be provided when an error
occurs. The first lines of this example provide the same information as was in the
database trace file with no errors: connection parameters, update mode indicator,
table column descriptions, SQL statements to be used, and so on.
However, after the UPDATE statement, the database trace file provides details to
assist in determining the problem. The Message line indicates that an attempt was
made to insert a row with a NULL value for the EVENT.MEMBERSHIP.LASTNAME
column that cannot contain a NULL. To further identify the row in the output data
causing the error, the database trace file lists the values for all of the columns in
the row causing the error.
The remaining lines in the database trace file display information about the
disposition of the entire database card transaction. The transaction failed after one
row was inserted. The database adapter returns an error code of -9 to the
Launcher with a corresponding error message of Failed to execute the SQL
statement. If you produced the audit log, you would see the following line in the
execution summary section:
<TargetReport card="1" adapter="DB" bytes="1218" adapterreturn="-9">
<Message>Failed to execute the SQL statement</Message>
<TimeStamp>22:07:32 January 8, 2004</TimeStamp>
</TargetReport>
Subsequently, the database trace file communicates that the database adapter is
cleaning up and closing the transaction. Because the OnFailure setting was set to
Rollback for this output card, the final entry in the database trace reveals that the
transaction rollback was successful.
The following database trace example was produced using the same map and data
as in the preceding example, now additionally using -BADDATA.
.
.
Error in: oexec
Message : ORA-01400: cannot insert NULL into
("EVENTMGT"."MEMBERSHIP"."LASTNAME")
The following values were being inserted:
Column 1 MEMBERID : D190-0002
Column 2 FIRSTNAME : Leverling
Column 3 LASTNAME : NULL
Column 4 TITLE : Vice President-New Products
Column 5 COMPANYNAME : Northwind Traders
Column 6 ADDRESS : 722 Moss Bay Blvd.
Column 7 CITY : Kirkland Column 8 STATEORPROVINCE : WA
All of the information in this trace file example is the same as the previous
example except for the bold lines of text. In this example, because -BADDATA was
used, the database adapter goes on to process all of the other rows produced for
the target. Upon completion, four rows were successfully inserted, two rows were
successfully updated, and one row was rejected. The rejected record was saved in
the file specified with the Bad Data adapter command (-BADDATA). In this example,
the rejected record was saved to a file called badstuff.txt.
The remaining lines in the database trace file indicate information about the
disposition of the entire database card transaction. Notice that the use of -BADDATA
allows the card to successfully complete. The map successfully completes and the
transaction is committed.
If you produced the audit log, you would see the following line in the execution
summary section:
<TargetReport card="1" adapter="DB" bytes="1218" adapterreturn="1">
<Message>One or more records could not be processed</Message>
<TimeStamp>22:07:32 January 8, 2004</TimeStamp>
</TargetReport>
If you forget to specify the usage of the update setting (using -UPDATE either in the
PUT → Target → Command setting in the Map Designer or Integration Flow
Designer or in the command line), you may receive a database error resulting from
the attempt to insert a row with a duplicate index.
The first entry in this example highlighted in bold type indicates that update mode
is off. Because update mode is off, the database adapter attempts to insert a row
into the database table for each row produced by the map. The Message entry
contains the message returned by the database driver to the database adapter
describing the cause of the error. In this example, the row in error would violate
the UNIQUE_MEMBER_ID constraint defined for the table. The next lines show
the column values for the row in which the error occurred and the final result of
the database operation.
There are several possible methods for resolving this problem. Depending upon the
desired behavior, you might:
v Enable update mode when executing the map by using the -UPDATE ON or
-UPDATE ONLY adapter command.
v Use the Delete adapter command (-DELETE) to remove all rows from the output
database table before inserting the rows resulting from map execution.
v Build logic into your map to ensure that there is no existing row in the table
prior to generating an output row to be inserted. This might be accomplished by
are included in this trace file as shown in the example above. Note that no records
were retrieved because the DELETE statement does not return data.
The next series of statements are produced for an output card using a DBQUERY
function to obtain several columns from a database table based upon specified
values in the MEMBERID column in the input data.
..Starting a database unload...
Host string:
Userid : eventmgt
Password : ********
Query : SELECT FIRSTNAME, LASTNAME , EMAILADDR FROM EVENTMGT.MEMBERSHIP
WHERE MEMBERID = ’D191-0001’
Query size : 108
Output is to a buffer.
Statement execution succeeded.
The columns are of the following types:
Column 1 (FIRSTNAME) type is VARCHAR(30).
Column 2 (LASTNAME) type is VARCHAR(50).
Column 3 (EMAILADDR) type is VARCHAR(50).
Number of buffers in fetch array = 492
Writing results to a buffer.
Retrieved 1 records (40 bytes).
Size of DBQUERY data is 40.
The following data was returned from a DBQUERY:
Nancy|Davolio|nancyd@cascadecoffee.com
In this example, as in the previous one, the database trace file reports the actual
query to be executed. In this example, each DBQUERY returns a single row
containing the three columns from the Membership table for the specified
MEMBERID. The data returned by the DBQUERY function conforms to the
Delimited Row group format type tree definition, meaning that there will be a
pipe character (|) delimiter between columns and a carriage return/line feed
terminator for each row of data.
The size of the data returned by the DBQUERY is also listed. Note that the size of the
DBQUERY data is specified as 42. This value represents the length of the data,
including the carriage return/line feed that follows the row of data. There will be a
similar set of entries in the database trace file for each DBQUERY executed.
Use the Trace Error adapter command (-TRACEERR) to minimize the amount of
information contained in the database trace file (map_name.dbl). This file contains
only the database errors occurring during the map execution.
When -TRACEERR is specified, the database trace file is produced using the full
name of the MDQ with a .dbl file name extension instead of the usual trace (.mtr)
extension. It is created in the directory in which the map is located. Use the
-TRACEERR filename syntax as described in the Resource Adapters documentation to
specify the name for the database trace file.
For example, if you generate the full database trace for a map called DBUpdate
that has three database input cards, it would produce the following 88-line
MultiDB’s.dbl file.
After reviewing this file, notice that the query for input card number 3 (SELECT *
FROM Title) failed because it references an object name (the table name Title) that
does not exist. Alternatively, you could use the Trace Error adapter command
(-TRACEERR) for each of the three input cards and produce the following database
trace file:
Invalid object name ’Title’.
This file can be used along with the following execution audit log information:
<SourceReport card="1" adapter="DB" bytes="1810" adapterreturn="0">
<Message>Success</Message>
<TimeStamp>01:02:00 January 9, 2004</TimeStamp>
</SourceReport>
Use this information to determine whether the query defined for input card 3
references a table or view that does not exist.
However, you can use Backup settings to capture the data retrieved from or
written to the database for debugging purposes.
The rejected record(s) is/are saved in the file specified with the -BADDATA adapter
command.
When the -BADDATA adapter command is used and one or more rows are rejected,
the database adapter returns an adapter return code of 1 with a message of One or
more records could not be processed as shown in the following TargetReport
excerpt in the execution summary section:
<TargetReport card="1" adapter="DB" bytes="1218" adapterreturn="1">
<Message>One or more records could not be processed</Message>
<TimeStamp>22:07:32 January 9, 2004</TimeStamp>
</TargetReport>
The default is to produce a file named audit.dbl in the directory in which the map
is located. Optionally, you can append the audit information to an existing file or
specify a name or the full path for the file. For more information, see the Resource
Adapters documentation.
The database adapter audit file provides the following details for each database
access:
v Execution Time (Audit Time)
This is the amount of clock time (in seconds) the database adapter takes to
execute the database action (for example, the retrieval of all rows for a data
source, a single instance of aDBLOOKUP function, and so on).
v Adapter Return Code (AC)
Trace utilities
For example, when using ODBC data sources on a Windows platform, enable
ODBC tracing from the ODBC Data Source Administrator window. This creates a
log of the calls to ODBC drivers as you use the Database Interface Designer to
define databases and queries, and when you use an Launcher to run maps that
have database sources or targets. Similar tracing tools are available for most of the
other database systems. For information about the tracing capabilities available for
your database system, see the documentation for your RDBMS.
These tools provide the ability to determine the problem by testing your queries
against the database using the same drivers being accessed by the database
adapters.
For example, if you run a map that executes a query for a data source and it fails
because one or more of the column names was invalid, you could copy the query
text from the Database Interface Designer and test it using the SQL command tool
for your database. Then, you could modify the query as necessary to get it to work
Similarly, if a database insert or update operation fails, you could try entering the
corresponding INSERT or UPDATE statement into your database system’s SQL
command tool to help determine the cause of the failure.
IBM may not offer the products, services, or features discussed in this document in
other countries. Consult your local IBM representative for information on the
products and services currently available in your area. Any reference to an IBM
product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may
be used instead. However, it is the user’s responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this document. The furnishing of this document does not grant you
any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
IBM World Trade Asia Corporation Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106-0032, Japan
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law:
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those Web
sites. The materials at those Web sites are not part of the materials for this IBM
product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
The licensed program described in this document and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Program License Agreement or any equivalent agreement
between us.
All statements regarding IBM’s future direction or intent are subject to change or
withdrawal without notice, and represent goals and objectives only.
This information contains examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
names of individuals, companies, brands, and products. All of these names are
fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
If you are viewing this information softcopy, the photographs and color
illustrations may not appear.
However, this information may also contain diagnosis, modification, and tuning
information. Diagnosis, modification and tuning information is provided to help
you debug your application software.
i5/OS
IBM
the IBM logo
AIX
AIX 5L
CICS
CrossWorlds
DB2
DB2 Universal Database
Domino
HelpNow
IMS
Informix
iSeries
Lotus
Lotus Notes
MQIntegrator
MQSeries
MVS
Notes
OS/400
Passport Advantage
pSeries
Redbooks
SupportPac
Tivoli
WebSphere
z/OS
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the
United States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of
Microsoft Corporation in the United States, other countries, or both.
Notices 97
Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo,
Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or
registered trademarks of Intel Corporation or its subsidiaries in the United States
and other countries.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Index 101
V
values
returned from stored procedures 62, 63
variables
passing values at run time 22
syntax for defining in a query 21
View menu 7
commands 7
views
generating a type tree from 23, 25
W
When expression 74
formats used for 75
table column format example 75
table SELECT 1 FROM format example 75
Window menu 9
commands 9
Printed in USA