The IBM Explorer - Page 3
June 7, 2005
Creating a database
It is pretty basic, but you can create (and drop) a database from the IBM Explorer, as shown below:
This option creates a default DB2 UDB database with the default table space definitions, and so on. In essence, this is the same as entering the CREATE DATABASE TESTMEOUT command from a DB2 UDB command prompt. While this functionality may not be 'rich' enough for a production database, it is a convenient option for creating local development databases.
Asynchronous operations with minimal blocking
For most databases, the Server Explorer operates in a synchronous manner. If you expand a server with SQL Server or DB2 UDB instances that are not started, the entire IDE is blocked until either a login window is returned (which can take some time when the instance isn't started) or an error is returned to the IDE.
Because the IBM Explorer caches the database schema, the amount of blocking that can occur is minimized. In addition to this, certain operations in the IBM Explorer that block the interface only block the IBM Explorer interface and not the rest of the IDE.
Creating schema objects
There are a number of wizards that are directly accessible from the IBM Explorer. Typically, developers will use these options to synchronously create objects in their development databases. (Of course, you can only perform actions that your DBA has authorized you to do.)
The following figures show the wizard that assists in creating a DB2 UDB SQL/PL procedure:
I will discuss the schema creation wizards in the next article in this series, but for now look at the following figure from the SQL/PL wizard:
Notice in the preceding figure that the DB2 UDB add-in for VS.NET was able to flag an error in the SQL statement that this stored procedure is based on. Users of other databases might have to wait until run built time to surface this error. This is the schema cache underneath the IBM Explorer that is busy at work ensuring that you remain as productive as possible.
You also can browse data from objects in the IBM Explorer in a native Microsoft data grid (shown in the figure below), as well as perform INSERT, DELETE, and UPDATE operations if you have the correct privileges to perform these operations.
From the IBM Explorer you can also execute routines that you have created. For example, I create a stored procedure called STAFF2000, which takes an Integer-type input variable (which represents a department number) and returns a list of the employees that work in that department.
The following figure shows executing a stored procedure called STAFF2000, passing it an input variable, and viewing the results in a native Microsoft data grid:
Generating CREATE scripts
You can select the Generate Create Script option to generate a creation script for the object you select. (You cannot do this on some objects.) When you select this option, you are presented with the following window:
This window allows you to add script fragments (headers and trailers) to the script, and choose where to deploy the script. When you select this option, it has the effect of running the db2look command, which generates the data definition language (DDL) code to create the selected object, as shown below:
You can then use the Insert Create Script option to add the script to, and use it in, some other database, or check it into your source control program, and so on.
Wrapping it all up
In this article, I showed you how friendly the IBM Explorer is for Microsoft developers. Aside from the natural drag-and-drop code generation experience that .NET developers who program to SQL Server are already accustomed to, there are a host of unique features that really create a rich development environment, no matter what DB2 UDB database you are programming to.
When you consider that most of the features I mentioned in this article apply to any DB2 UDB database product on any platform, you should start to get the feeling that learning about the DB2 UDB VS.NET add-ins can truly enrich your resume, let alone your development environment. In the next article in this series, I will talk about the schema wizards I briefly mentioned in this article.
Are you ready to try it out for yourself? Get a free trial copy of a DB2 UDB for Windows server at: http://www14.software.ibm.com/webapp/download/category.jsp?s=c&cat=data. You can also get a free copy of DB2 UDB Personal Edition for development purposes at: http://www14.software.ibm.com/webapp/download/search.jsp?go=y&rs=db2udbpde.
About the Author
Paul C. Zikopoulos, BA, MBA, is an award-winning writer and speaker with the IBM Database Competitive Technologies team. He has more than nine years of experience with DB2 products and has written numerous magazine articles and books about it. Paul has co-authored the books: DB2 Version 8: The Official Guide, DB2: The Complete Reference, DB2 Fundamentals Certification for Dummies, DB2 for Dummies, and A DBA's Guide to Databases on Linux. Paul is a DB2 Certified Advanced Technical Expert (DRDA and Cluster/EEE) and a DB2 Certified Solutions Expert (Business Intelligence and Database Administration). Currently he is writing a book on the Apache Derby/IBM Derby database. You can reach him at: firstname.lastname@example.org.
IBM, DB2, DB2 Universal Database, z/OS, i5/OS, and WebSphere are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
Intel is a trademark or registered trademark of Intel Corporation in the United States and other countries.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, and service names may be trademarks or service marks of others.
Copyright International Business Machines Corporation, 2005. All rights reserved.
The opinions, solutions, and advice in this article are from the author's experiences and are not intended to represent official communication from IBM or an endorsement of any products listed within. Neither the author nor IBM is liable for any of the contents in this article. The accuracy of the information in this article is based on the author's knowledge at the time of writing.