Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» Database News
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner


















A Year For Smarter Phones, Crowded Clouds

Hardware Vendors Face a Storm of Uncertainty

China Blocking NYTimes.com Access

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2 | Swynk







Related Articles
DB2 9.5 and IBM Data Studio Part 9: The SQL Editor Development Accelerators
DB2 9.5 and IBM Data Studio: Part 7: The SQL Builder’s Development Accelerators
DB2 9.5 and IBM Data Studio: Building an SQL Statement
DB2 9.5 and IBM Data Studio: Using OLE DB to Integrate Data

Sr. Business Systems Analyst
Professional Technical Resources
US-WA-Seattle

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

DB2

March 17, 2008

DB2 9.5 and IBM Data Studio: Part 8: The SQL Builder Development Accelerators – The Rest of the Story

By Paul Zikopoulos

So far in this series about the IBM Data Studio integrated development environment (IDE) that’s available with DB2 Version 9.5 (DB2 9.5), I’ve shown you how to set up database connection objects and the actions that you can perform on them. In addition, I introduced you (in Part 2) to some of the features available in the Database Explorer view, and Part 3 and Part 4 gave you a full tour of overview diagrams. In Part 5, you learned how to point-and-click your way to OLE DB functions that can integrate data from external data sources that have an OLE DB provider. In Part 6, I showed you how easy it is to create an SQL statement using the IBM Data Studio SQL Builder. Part 7 introduced you to a set of rapid application development features within IBM Data Studio that takes your SQL development capabilities to a whole new level. Specifically, I introduced you to my favorite SQL Builder features: namely, SQL Assist, Content Tip, colorization, and the design-time parser. In this installment, I finish the tour of the SQL Builder features that help you get to an extreme development paradigm.

Things you have to do to follow the examples in this article...

I recommend for that all the multi-part articles I write that you start with Part 1 because I tend to build on the concepts and objects created in these series sequentially. For this article, I assume that you’ve read through Part 7 and your Database Explorer view looks like this:

More Development Assistance from the SQL Builder

In this section, I’ll detail the rest of the SQL Builder features that help boost productivity when you’re designing SQL statements using the FEMALEPERSONNEL2 query, which we built in Part 7 of this series.

Standard Editing Functions

IBM Data Studio comes with a number of basic text editing capabilities such as cut, copy, and paste, that users of word-processing software, spreadsheets, and more are accustomed to. As well, there are more advanced features such as undo, revert, format, indent, and so on. These features really come in handy when you are designing SQL statements.

To access the basic editing features (I’ll cover some of the more advanced ones in a bit), simply right-click within the design canvas of the SQL Builder:

Revert to Last Correct Source

Quite often, you’ll find yourself editing your SQL and making a mistake (or perhaps it’s just me). The Revert to Last Correct Source option comes in very handy. For example, add a D to the DEPARTMENT table name such that it looks like:

Now save this SQL statement (press Ctrl+S). You should receive an error message similar to this:

The SQL Builder is smart enough to see that this table doesn’t exist, and alerts you to this error when you try to save the statement. Click OK and then press Ctrl+S to override the real time parser in IBM Data Studio and save the query with the error.

Note: Make sure you save your SQL statement to enable this option. You can tell that your statement hasn’t been saved when an asterisk (*) prefixes the name of the SQL statement. When a statement is successfully saved (even with an error) the asterisk disappears, as shown below:

To have IBM Data Studio return the SQL statement to the last known version of it that worked, right-click in the SQL Builder and select Revert to Last Correct Source. IBM Data Studio will open a window that contains that last SQL statement that it successfully parsed. You can probably figure out what happens if you click OK at this point:

As you can see in the previous figure, IBM Data Studio changed the SQL statement back to the last time the SQL you wrote was valid. I like this feature because I often work off an SQL template, a stub file, or some sample SQL statement that I copied from the DB2 documentation or some article. If I mess it up, I know that I’ve got IBM Data Studio watching my back. What’s more, it seems that IBM Data Studio can remember that last version of your SQL statement that worked even after you close and subsequently reopen your SQL statement; that means the ‘state’ of the help engine persists across editing sessions!

Clear to Template

This option takes your SQL statement, as well as any changes you’ve made, and replaces it with the original template you worked with. For example, create the same error in the SQL statement that you just did in the previous section, but this time select the Clear to Template option.

If you recall from Part 5, we created an SQL statement using the SELECT template, and this is why the SQL statement reverted back to what’s shown below:

In this case, don’t save the SQL statement; just close it by clicking . By now you’re likely wondering why you would want to leverage this option. After all, you just spent time writing a full SQL statement, adding tables, specifying an ordering for the result set, and more.

In this example, we built the SQL statement from a simple SELECT statement. As you likely noticed, the built-in templates in the SQL Builder are very simple. The good news is that you can create customized templates that you can leverage within the SQL Editor (they are not available within the SQL Builder at this present time, but I expect that to change) and revert back to the template you defined. (I’ll introduce you to templates in the next section and discuss the SQL Editor in the next article.) If you recall, I’ve discussed how you would use a combination of the SQL Builder and the SQL Editor. For example, despite the fact that we created the FEMALEPERSONNEL SQL statement using the SQL Builder, you can subsequently open it using the SQL Editor and get all of the functionality that’s only available within the SQL Editor (such as templates) for your SQL statement:

In the future, these two editors may be merged into a single editor. One thing to note, however: there may come a point at which your SQL statement gets too complex for the SQL Builder and can only be opened in the SQL Editor. Those of us who have to write SQL statements daily as part of our jobs will likely feel the SQL Editor is the right trade-off between personal knowledge and design assistance.

Run your SQL

It’s good to know that you can run your SQL statement directly from the SQL Builder. This handy option enables you to quickly look at the result set for your SQL statements with a click of a button. Now think about extending such a benefit when you are in the Java perspective and writing a Java application. Forget about the fact that IBM Data Studio gives you SQL assistance when in the Java perspective, but the fact that you don’t have to write Java code or create a JUnit program to run your SQL is the big benefit here. These topics are outside the scope of this article, but this simple feature will prove to be very beneficial through the data lifecycle management process that I outlined in “DB2 9.5 and IBM Data Studio: Things I Couldn’t Tell You before DB2 9.5 Was Announced”.

Go to page: 1  2  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

DB2 Archives







Latest Forum Threads
DB2 Forum
Topic By Replies Updated
SQL where clause reference modification sudhakarnalluri 0 December 17th, 06:42 PM
database files move????? db2dba 3 December 16th, 01:32 AM
How to build db2 cmd with embedded quotes using C# mmclendon 0 December 3rd, 12:16 PM
DB2 certification clarify varunkrish 1 November 25th, 11:08 AM








internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers