Enabling Agile Development with Toad – Part 2 Implement the automation components of Toad Development Suite for Oracle: Team Coding, Code Analysis, SQL Optimizer and Code Tester

Written by John Pocknell, Senior Product Manager, Quest®

What does it take to make your database development as agile The components touch four areas of interest in automating as your application development? database development:

As we pointed out in Enabling Agile Database Development 1. Access to source control with Toad – Part 1, the road to agile database development 2. PL/SQL unit testing leads away from traditional, manual processes and toward fully automated pipelines that streamline work and minimize the 3. Code reviews risk of data loss or downtime. Together, Toad Development Suite for Oracle and Toad Intelligence Central offer automation 4. SQL and PL/SQL optimization for synchronizing the development cycles of your application SETTING UP THE ENVIRONMENT software teams and database teams. As depicted in Figure 1, the implementation of Toad Now, in part 2 of this technical brief, the focus is on Team Development Suite for Oracle includes Toad for Oracle running Coding, Code Analysis, SQL Optimizer and Code Tester, on development staff desktops. It also calls for various Toad components of Toad Development Suite for Oracle. repositories and integration with version control systems. Development Sta Desktops Continuous Integration Server • Jenkins • Hudson Toad • Bamboo • Team City

Toad Development Suite for Oracle

Development Projects Management Reporting Source Toad Intelligence Code Central • Formatter Templates For collaboration, • Code Analysis Rule Sets • Automation Team Coding is a • Database Connections • Team Coding Objects utility that integrates VCS Providers with your version Figure 1: Relationships among , version control and Toad products control system.

Toad Intelligence Central runs on a Implementing Team Coding Windows server that all developers using For collaboration, Team Coding is a utility Toad can access (to be covered in Part 3 that integrates with your version control of this technical brief). system. Developers access PL/SQL code and other objects from the Oracle INSTALLING THE DEVELOPER database as usual, but Team Coding DESKTOP controls and monitors the check-out/ Install Toad Development Suite for check-in of the corresponding files in Oracle on development systems. It source control. Team Coding supports includes the following products: the following VCS providers:

• Toad for Oracle Xpert Edition (includes • Serena PVCS Version Manager SQL Optimizer for Oracle) • Microsoft Visual SourceSafe • Code Tester for Oracle • Microsoft Team Foundation Server • Benchmark Factory for Oracle • Microsoft Visual Studio Team Services • (from Toad 12.9)

• Toad for MySQL Freeware • Mercurial (from Toad 12.10)

The implementation also requires an • IBM Rational ClearCase Oracle client for Windows. The client should match the Oracle server in • Perforce version number and bit-width (32 vs. 64) • CVS as nearly as possible. Toad Development Suite for Oracle is flexible enough to • Git work with Oracle Instant Client. • Subversion (CollabNet recommended)

Toad for Oracle itself can be installed Normally, Team Coding requires a set directly on the Windows desktop using of repository tables to be installed in the web installer or a network package a schema in the Oracle database, but with silent installation. starting with Toad for Oracle v12.10, you

2 can have the Team Coding objects Sets, then share the rules across the installed into the Toad Intelligence members of each team. Code Analysis Central server. The result is a truly also includes a repository for storing the centralized repository for all your results of your code reviews. projects without the need to install Team Coding on each database instance. For more information on setting up and using Code Analysis, watch this video. For more information on setting up Team Coding with VCS integration, watch You can select an option in Team Coding this video. that will require a code review whenever developers try to check their code into For information on the usage of Team source control. Toad for Oracle will Coding with VCS, watch this video. prevent any code that does not meet the required quality levels from being Implementing Code Analysis checked in until the problems are fixed. Code Analysis is a rules-based feature for code review. It comes with approximately For more information on setting Team 200 pre-defined coding rules across Coding policies, watch this video. a number of standard category Rule Another option is to publish the results You can select an Sets such as Program Structure, of code reviews to the Toad Intelligence Maintainability and Efficiency. As shown Central, which presents historical option in Team Coding in Figure 2, you can use your own coding trending and event-based information standards and create your own Rule through its web server. that will require a code review whenever developers try to check their code into source control.

Figure 2: Creating a new Rule Set in Code Analysis and selecting rules from the library

3 Auto Optimize SQL generates multiple rewrites of your Figure 3: PL/SQL Profiler identifying a slow-running SQL statement inside a original SQL statement PL/SQL program until it finds one that executes more quickly. Optimizing SQL and PL/SQL execution of each line of PL/SQL code as When a PL/SQL program runs slowly, the program runs. PL/SQL Profiler stores you try to pinpoint the bottleneck. If the data in a repository and represents the problem is a poorly written SQL it graphically, as shown in Figure 3. statement, you then try to improve Any performance bottlenecks become it. Toad and SQL Optimizer handle the immediately apparent. process in two steps. For more information on setting up and using PL/SQL Profiler, watch this video. Step 1 – Profiling PL/SQL The PL/SQL Profiler feature in Toad works in conjunction with the Editor to time the

4 With Code Tester you Figure 4: Auto Optimize SQL automatically finding a faster SQL alternative describe your tests based on your use

Step 2 – Optimizing the SQL The Auto Optimize SQL feature (see cases, and the tool Next, use SQL Optimizer in Toad to Figure 4) will then start generating generates test code relieve the bottlenecks. SQL Optimizer multiple rewrites of your original SQL automatically reforms the statement statement until it finds one that executes as a PL/SQL package to remove any PL/SQL-specific more quickly. It presents execution plans that implements your elements, such as INTO statements, and and statistics to help you select the best converts locally declared variables to alternate statement. test definition. bind variables. For more information on using Auto Optimize SQL, watch this video.

5 With Code Tester, you don’t write test code. You describe your tests and the tool

generates test code Figure 5: Creating a PL/SQL unit test in Toad that implements your

test definition. IMPLEMENTING CODE TESTER The Code Tester repository needs to be FOR ORACLE installed on the same database where Testing code is a double-edged your developers will be defining their sword. Developers know that testing is tests. You can enable public or private important, but it often involves writing access to the repository depending on a large volume of test code, keeping your requirements. that test code in synch with changes in Creating unit tests in Toad Editor application code, verifying test results and taking other steps that effectively As shown in Figure 5, you can create unit keep developers from their highest- tests directly in Toad for Oracle and store value work. them in the Code Tester repository. The process creates reusable tests that will Code Tester for Oracle makes it easy to be stored for ongoing regression testing define tests, generate test code and run throughout the lifetime of the code. tests, all within an easy-to-use graphical interface. Best of all, with Code Tester In Toad Editor, when you execute the you don’t write test code. You describe code normally, Code Tester uses any your tests based on your use cases, input and output values to create the and the tool generates test code as a unit test definition, which it then stores in PL/SQL package that implements your its repository. test definition. For more information on creating PL/SQL Code Tester stores execution data from unit tests in Toad, watch this video. unit tests in the repository whether you execute the tests directly from the Toad Editor or from Code Tester itself.

6 The Run-to-Test Figure 6: Creating a PL/SQL unit test in Code Tester using Run-to-Test feature provides Creating unit tests in Code Tester CONCLUSION more-comprehensive In Code Tester, the simplest way to It takes automation to make your options for defining create unit tests is to use the Run-to-Test database development as agile as feature. It provides more-comprehensive your application development. The input values and options for defining input values and combination of Toad Development expected outcomes. Suite for Oracle and Toad Intelligence expected outcomes. Central offers database developers As noted above, all unit tests, whether strong advantages in catching up with created in Toad or Code Tester, will be agile application development through stored in the Code Tester repository. automated features like Team Coding, There you can view all your tests, test Code Analysis, PL/SQL Profiler, SQL suites and PL/SQL code (see Figure 7). Optimizer and Code Tester. Database developers now have the opportunity For more information on creating to shorten development cycles while comprehensive PL/SQL unit tests in minimizing risk. Code Tester, watch this video.

Figure 7: Code Tester main window showing Test Builder (inset)

7 ABOUT THE AUTHOR areas, and he has run many Toad John has worked in IT for almost 30 training courses for customers. John years, most of that time in Oracle John Pocknell is a senior manager of has spent the last 15 years successfully application design and development. product management at Quest. Based at evangelizing Toad to customers at He is a qualified aeronautical engineer the European headquarters in the U.K., various events throughout Europe, the with more than 10 years of experience in John is responsible for the Toad product U.S. and the Asia-Pacific region. John provisioning IT consultancy services and portfolio. He has been with Quest since writes many blogs and papers that are implementing quality assurance systems 2000, working in the database design, published on the Toad user community, to ISO 9001. development and deployment product Toad World.

8 ABOUT QUEST Quest helps our customers reduce tedious administration tasks so they can focus on the innovation necessary for their businesses to grow. Quest® solutions are scalable, affordable and simple-to-use, and they deliver unmatched efficiency and productivity. Combined with Quest’s invitation to the global community to be a part of its innovation, as well as our firm commitment to ensuring customer satisfaction, Quest will continue to accelerate the delivery of the most comprehensive solutions for Azure cloud management, SaaS, security, workforce mobility and data-driven insight.

© 2017 Inc. ALL RIGHTS RESERVED.

This guide contains proprietary information protected by copyright. The software described in this guide is furnished under a software license or nondisclosure agreement. This software may be used or copied only in accordance with the terms of the applicable agreement. No part of this guide may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording for any purpose other than the purchaser’s personal use without the written permission of Quest Software Inc.

The information in this document is provided in connection with Quest Software products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Quest Software products. EXCEPT AS SET FORTH IN THE TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS PRODUCT, QUEST SOFTWARE ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL QUEST SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF QUEST SOFTWARE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Quest Software makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Quest Software does not make any commitment to update the information contained in this document.

Patents

Quest Software is proud of our advanced technology. Patents and pending patents may apply to this product. For the most current information about applicable patents for this product, please visit our website at www.quest.com/legal

Trademarks

Quest, and the Quest logo are trademarks and registered trademarks of Quest Software Inc. in the U.S.A. and other countries. For a complete list of Quest Software trademarks, please visit our website at www.quest.com/legal. All other trademarks, servicemarks, registered trademarks, and registered servicemarks are the property of their respective owners.

If you have any questions regarding your potential use of this material, contact:

Quest Software Inc. Attn: LEGAL Dept 4 Polaris Way Aliso Viejo, CA 92656

Refer to our Web site (www.quest.com) for regional and international office information.

9

TechBrief-ToadDevSuite4Oracle-Part2-US-KS-24530