SQL Wizard


The purpose of the SQL Wizard is to allow you to quickly generate the source necessary to perform a SQL command on the server while at the same time avoiding the chance of a typo, misplaced quote or invalid syntax that would otherwise slow your development effort. We're sure you'll find this to be a great time saving feature. Not only does the wizard create the SQL, it also creates the Java code to run it. As an added feature you can run the SQL's on the fly and get the results just to be sure the SQL is what you really wanted.

The SQL Wizard consist of three tabs. They are as follows:

Select Database

For more detailed information see Selecting a Database.

Define SQL Statement

This tab allow you to choose the from the following types of SQL that can be run on the server:

Based upon the type of SQL you choose to perform the screen with display a layout that allows you to quickly construct the SQL simply by selecting items from lists and combo boxes. The combo boxes allow you to enter constant values for parts of the SQL or choose variables and methods to use to load and unload data from the selected table(s).

When multiple tables are selected each is prefixed with a letter. You can then define the join conditions in the where clause by referencing the a and b column names.

Tip: if you are running the SQL Wizard from the SQL Interactive option of the tools menu you also have the ability to simply type any SQL command you like into the SQL area and run it. This provides the ability to create and drop tables and indexes along with other extended SQL functions.

For more help on constructing SQL's see either the tutorials or the multimedia examples available on our website.

When you have constructed the SQL and are happy with it press Done to create the source necessary to run this SQL. If the cursor was positioned in an existing method the source will be inserted where the cursor was. If the cursor was on the first position of a method or no method was selected a new method will be created. You are free to change the generated source. Although the wizard retains the settings from the last time it was used it does not reverse engineer your source. What! you say, don't be do lazy, you can't expect it to do everything for you.

Show SQL Results

When you have successfully constructed your SQL you can run it to see the results returned. Note: there is no rollback facility in the SQL wizard so all updates you make to the database will be permanent. Use it with caution.

Press the Run SQL button. The first time you do this in an session a warning will be displayed. Press the button again to run the SQL. Once the SQL completes on the server the Show SQL Results tab will automatically be selected.

On the screen you will see the result code that was returned. This will generally be -1 if the SQL failed and >=0 if it was successful. The actual value usually represents the number of rows returned, updated, inserted or deleted depending on the function performed.

If you performed a select or a stored procedure that returns data the data returned will be displayed in the grid panel.