DB2 Developer Workbench (DWB) is a comprehensive development environment available for use with DB2 9. It is used to create, edit, debug, test, and deploy DB2 stored procedures and user defined functions, along with SQL, SQLJ, and XQuery APIs.
Available for Windows 32-bit and Linux 32-bit environments, it was formerly packaged with DB2 as the Development Center. This new DB2 Developer Workbench is based on Eclipse and features new XQuery Visual Builder.
Key features of DB2 Developer Workbench
DB2 Developer Workbench provides a universal toolset for DB2 solutions development based on the Eclipse project. In addition to the functionality of the previous Development Center, additional new features have been added. These include:
Creating New Project in DB2 Developer Workbench
You can start a new development project in DB2 Developer Workbench using two methods.
Selecting new data development project
New Project drop-down menu
Creating stored procedure
To create a stored procedure:
This prompts you for the project name. If new project creation is specified, you can specify the current schema as shown Below
Data development project for a stored procedure
Upon choosing the newly-created project name, the name of the stored procedure and the language of the procedure need to be specified as shown Below
Specifying language type for stored procedure
Before invoking the wizard, you need to create the Java project prior to the SQLJ creation using the wizard :
Creating a Java project
Specifying package and SQLJ name
Creating a user defined function (UDF)
Before creating UDFs, you need to create the data development project to store the given database object:
The data development project now displays in the Data Project Explorer view. Now, you can use the New User Defined Function wizard to create DB2 user defined functions (UDFs) in SQL.
Switching to Data perspective
Selecting user defined function wizard
By default, creating the user defined function does not register the user defined function on the database. To register the user defined function on the database, you must deploy it.
Creating XQuery using Visual Builder
DB2 9 allows you to write XQuery expressions directly rather than requiring that you embed or wrap XQueries in SQL statements. This is possible because the DB2 9 query engine processes XQueries natively. We cover more details regarding XQuery in future chapters.
With native XML capabilities added to DB2 9, IBM has enhanced development tools for use with DB2 9. One of the key development tools is DB2 Developer Workbench, which utilizes XML Query Language (XQuery) to query the XML data type. You can use Visual Builder to piece together queries, then review the DB2 Developer Workbench generated syntax.
The following walkthrough demonstrates the use of Visual Builder for the XQuery in DB2 Developer Workbench, which queries the name and city of the customer who has the city element defined with the data Toronto:
In the Workspace panel, enter the workspace directory. The workspace is the Eclipse platform component that holds the development environment. Select the Database Explorer tab in the workspace view . Expand the Connections folder. This should show SAMPLE[DB Alias]. Right-click SAMPLE[DB Alias] then select Reconnect. The User ID and password prompt window appears. Upon successful connect, the status in the Properties should change from <Disconnected Connection>SAMPLE to <Live Connection> SAMPLE [DB2 UDB V9.1].
XQuery Visual Builder: connecting to database
Use File → New → Data Development Project. You can make these same choices by clicking the New Project drop down from the tool menu. Name the project. In our example, XQuery1 was used as the project name. Click Next.
DWB: creating new project
XQuery Visual Builder: specifying the connection
Workbench can discover and generate the XML schema, but you can also add XSDs, DTD, and schema to the XML Schema Documents folder (This folder is located under the recently created project in the Data Project Explorer pane).
Right-click XML Queries and choose New XML Query. Name the query. Here we used Sample_XML_Query. Once you click Next, the Add representative XML documents window appears. Click the Add button on the right. On the Specify document location panel, choose Database. Select Next.
XQuery Visual Builder: specifying the document location
XQuery Visual Builder: specifying the document location
XQuery Visual Builder: specifying XML file name
XQuery Visual Builder: adding representative XML documents
XQuery Visual Builder: associating documents with XML columns
XQuery Visual Builder: XQM tab
XQuery Visual Builder: adding element to XQuery
The Step Into icon appears when name is highlighted. Use this to specify conditions and result sets for that node. Click the Step Into icon to step into the For Logic (FLWOR) window. FLWOR stands for FOR, LET, WHERE, ORDER BY, and RETURN, which represent basic XQuery syntax. We limit the query to cities with the name Toronto. So we expand theFunctions, String functions, choose fn:matches and drag it to the Operand1 column of the Where section. This populates the Operand 1 column in Where with matches(…) and the Step Into icon appears next to matches(…).Click the Step into icon.
XQuery Visual Builder: For Logic (FLWOR) window
The fn:matches function does not take a second operand (Operand 2), so we leave that column empty (as well as Operator).
XQuery Visual Builder: matches window
To do this, drag the city node from the navigation pane on the left to the Return section of the For Logic (FLWOR) window.
XQuery Visual Builder: For Logic (FLWOR) window with operand 1
XQuery Visual Builder: source tab
You can execute the following source code that DB2 Developer Workbench generated in Command Editor with minor modification.
Generated source code
You can execute the same query from the script file.
It is the syntax for the XMLQuery. We can modify the source for XQuery
Save the source , then issue the following command:db2 -td@ -vf xquery.db2
XQuery Visual Builder: Data Output tab
XQuery Visual Builder: XQuery results
IBM DB2 Related Interview Questions
|IBM Websphere Interview Questions||IBM-REXX Interview Questions|
|IBM Cognos Interview Questions||IBM DB2 Interview Questions|
|J2EE Interview Questions||COBOL Interview Questions|
|IBM-JCL Interview Questions||DB2 Using SQL Interview Questions|
|IBM WAS Administration Interview Questions||IBM WebSphere Administration Interview Questions|
|Database Administration Interview Questions||DB2 SQL Programming Interview Questions|
|Mainframe DB2 Interview Questions|
IBM DB2 Related Practice Tests
|IBM Websphere Practice Tests||IBM Cognos Practice Tests|
|IBM DB2 Practice Tests||J2EE Practice Tests|
|COBOL Practice Tests||IBM-JCL Practice Tests|
|DB2 Using SQL Practice Tests||IBM WAS Administration Practice Tests|
|Database Administration Practice Tests||DB2 SQL Programming Practice Tests|
Ibm Db2 Tutorial
Db2 Application Development Overview
Application Development With Db2 Purexml
Application Development With Php
Application Development With C/c++
Application Development With Java
Application Development With .net
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.