Documente Academic
Documente Profesional
Documente Cultură
Create DB2 DDL, DML and stored procedures using the Rational Application Developer Data and Debug perspectives
Skill Level: Introductory Debra R. Eaton (deaton@us.ibm.com) DB2 Software Information Technology Specialist IBM
15 Dec 2005 The IBM DB2 Universal Database (UDB) plug-ins for Rational Application Developer give developers the ability to connect, browse and alter DB2 databases. In this tutorial learn how the Rational Application Development perspectives, views and wizards assist you with defining and working with database object DDL such as schemas and tables. Learn how to create, execute and edit DML statements such as SELECTs and INSERTS. Create, execute, run, and debug DB2 stored procedures with the Rational Data and Debug perspectives.
Introduction to DB2 development with Rational Application Developer Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 1 of 10
developerWorks
ibm.com/developerWorks
objects; create and execute DML statements; and create, execute, and debug stored procedure routines using the Rational Application Developer (RAD) Data and Debug perspectives.
Objectives
In this tutorial, you learn about the RAD Data perspective, Debug perspective, Data Definition view, Database Explorer view, and the DB Output view. Step-by-step instructions give you hands-on experience in using the perspectives, views, and wizards.
Prerequisites
This tutorial is written for DB2 database developers, DB2 database administrators, and Rational developers whose skills using RAD for DB2 database development are at a beginning to intermediate level. You should have a general familiarity with database objects and working with a GUI interface.
System requirements
This tutorial was created with trial versions of Rational Application Developer (RAD) V6.0 and DB2 UDB V8.2 running on Windows XP. See resources for download information. The tutorial was written from the viewpoint of a new installation of the Rational software. The assumption is that all settings, views, and perspectives are set to the RAD default configuration. We will use the DB2 SAMPLE database. The operating system userid and password is used to gain access to DB2.
Introduction to DB2 development with Rational Application Developer Page 2 of 10 Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks
Open the Data Definition view Open the Database Explorer view Open the DB Output view
Start Rational
Open RAD on your Windows desktop.
Data perspective
Open the Data perspective to observe the relational database tools in the RAD workbench. The tools appear within the perspective as views and wizards.
Page 3 of 10
developerWorks
ibm.com/developerWorks
connections to an existing database, modify schema designs, and run database objects with results appearing in the DB output view. Using the Database Explorer view, you can: Create a database connection Define connection filters Connect to existing databases and view their designs Disconnect from a database if you are connected Import database designs to another folder in the Data Definition view, where you can extend or modify the designs Refresh the database objects that are defined for a database connection Delete a database connection Drag and drop database objects to the Data Definition view Generate an SQL DDL statement for tables and schemas Run sample contents and generate an XML schema for tables Run stored procedures and user-defined functions and view the results in the DB Output view Expand the Database Explorer view to observe all the features.
DB Output view
The DB Output view includes an actions list on the left side of the view. Messages, parameters, and results related to database objects that you manipulate appear on the tabbed pages on the right side. The tabbed pages on the right side of the DB Output view display information that is related to the actions list on the left side: A Messages page displays messages, including the progress of actions A Parameters page displays the parameters for a routine or object A Results page displays the results of SQL statements that are run by a routine The left side of the DB Output view contains the following fields: The Status field shows the current state of the statement The Action field shows what kind of action occurred
Introduction to DB2 development with Rational Application Developer Page 4 of 10 Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks
The Object Name shows the name of the statement Expand the DB Output view to observe all the features.
Debug perspective
In the Debug Perspective you can debug a DB2 stored procedure. You can provide input arguments, view results, set breakpoints, monitor variables, and run the stored procedure in debug mode.
Page 5 of 10
developerWorks
ibm.com/developerWorks
Define a project
In the Data Definition view, we will define a project for our database.
Define a database
In our project, we will define a database called MUSICDB using the New Database Definition wizard in the Data Definition view.
Define a schema
In our database we will define a schema called MYMUSIC using the New Schema Definition wizard in the Data Definition view. The schema is a collection of named objects. The schema provides a logical classification of objects in the database.
Define a table
In our schema, we will define a new table called FAVORITES using the New Table Definition wizard in the Data Definition view. The table consists of columns and rows. Tables are logical structures that are maintained by the database manager. Table 1. Table columns
Column Name TITLE CATEGORY ID Data Type VARCHAR VARCHAR INTEGER
Introduction to DB2 development with Rational Application Developer Page 6 of 10 Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks
server can be on the local computer or remote server. In this section we will deploy our MUSICDB data definitions to a database server outside of the workbench. The database must exist on the DB2 server before you deploy the database from the workbench. In this section we will accomplish the following tasks: Define a database on the server Deploy database objects to a database server
Introduction to DB2 development with Rational Application Developer Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 7 of 10
developerWorks
ibm.com/developerWorks
4.
Execute each statement and check the DB Output view for successful execution.
Introduction to DB2 development with Rational Application Developer Page 8 of 10 Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks
Introduction to DB2 development with Rational Application Developer Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 9 of 10
developerWorks
ibm.com/developerWorks
Resources
Learn The Rational training site and DB2 training sites list several learning delivery methods for the use of DB2 and Rational. Visit the developerWorks Rational zone and the developerWorks DB2 zone to expand your skills. Stay current with Rational events and DB2 events via developerWorks technical events and Webcasts. Get products and technologies Download a free trial version of DB2 Universal Database Enterprise Server Edition V8.2. Download a free trial version of Rational Application Developer for Websphere Software V6.0. Build your next development project with Rational trial software and DB2 trial software, available for download directly from developerWorks. Discuss Participate in the discussion forum for this content.
Trademarks
IBM, DB2, DB2 Universal Database, and Rational are trademarks of IBM Corporation in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
Introduction to DB2 development with Rational Application Developer Page 10 of 10 Copyright IBM Corporation 1994, 2005. All rights reserved.