Work with SQL Statements

OVERVIEWOverview

PROCEDUREProcedures  REFERENCEReference

Overview

Use SQLEditor to create, view, and manage SQL statements that XLiRAD templates use for retrieving data from and posting data to the database. The SQLEditor window provides access to the menu commands and toolbar buttons used to accomplish these tasks.

Procedures

Start SQLEditor

  1. From the Start menu, point to Programs, and click SQLEditor.
  2. Complete the XLiRAD Client Login dialog box and click Submit.
  3. Complete the Group Selection dialog box and click Submit.

Find a Statement

  1. In SQLEditor, click searchkeyword.gif .
    Or click the Keyword Search menu command.
  2. In the SQL Search dialog box, type a text string to search for.
  3. Select the Case Sensitive check box if appropriate
  4. Click Search to start the search.
    Notice that SQLEditor displays statements that match the search criteria with highlighting. Click Remove Highlighting as appropriate.

Sort the Statement List

Find Templates Based on a Statement

  1. In SQLEditor, click search.gif .
    Or click the Template Search command.
  2. In the Search Results dialog box, view the templates listed under Matching Templates.
  3. When finished, click Done.

Create a New Statement with the SQL Wizard

  1. In SQLEditor, click addquery.gif in the toolbar.
    Or from the Query menu, click the Add New Query command.
  2. Click SQL Wizard.
  3. Under SQL Wizard, click Next to continue.
  4. Under SQL Wizard: Step 1, accept the default database name or use the up or down arrow in the Database list box to find a database for the new statement. Then click Next.
  5. Under SQL Wizard: Step 2, accept the default query type or use the up or down arrow in the Query Type list box to find a query you want to use for the new statement. The options are SELECT (default), INSERT, UPDATE, and DELETE. Click Next to continue.
  6. Under SQL Wizard: Step 3, click one or more tables to use under Available Tables. To include multiple tables in a SELECT statement, hold down the CTRL key while clicking the names of the tables. Click Next to continue.
  7. Under SQL Wizard: Step 4 , click one or more columns to use. To include multiple columns in a SELECT statement, hold down the CTRL key while clicking the names of the columns or click Select All as appropriate. Click Next to continue.
  8. Under Select Statement Order, use the up or down arrows to arrange the field-specific variables in your statement. By default the list box shows these variables in the sequence in which the fields occur in your database. Click Submit to continue.
  9. Under SQL Wizard Final Step: Clauses, click Add Clause if you want to define a clause that limits the data returned by your statement. To define a clause, specify the following:
  10. Click Finish.

Create a New Statement "From Scratch"

  1. In SQLEditor, click addquery.gif in the toolbar.
    Or from the Query menu, click the Add New Query command.
  2. In the Command Editor dialog box, type the query text and the command ID of the new statement and click the name of the appropriate database. Use Add Form Data as needed.
  3. Click  Execute to validate the statement. To retrieve a statement from the server, click Refresh.
  4. Click Submit to save the statement to the server.
Tip

For a visual reference to the database schema, display the Database Layout window while creating a new query.

Duplicate a Statement

  1. In SQLEditor, right-click a statement and click Clone.

    SQLEditor displays the cloned statement in the Command Editor dialog box.
  2. Type a new command ID for the statement you are creating and make any other changes as needed.
  3. Click Execute to validate the statement or click Submit to save the statement to the server.

View or Update a Statement

  1. In SQLEditor, right-click a statement and click Update.
    Or click a statement and click Edit SQL in the toolbar.
  2. In the Command Editor dialog box, change any of the following settings:
  3. Click Execute to validate the settings or Update to save the changes.

Delete a Statement

  1. In SQLEditor, right-click a statement and click Delete.
    Or click a statement and click Delete SQL on the toolbar.
  2. Click Yes.

View Database Layout

  1. In SQLEditor, click dblayout.gif in the toolbar.
    Or from the Query menu, click the Database Layout command.
  2. For a selected database, view the table and field information as needed. For more information, see Database Layout Window Help.
  3. When finished, click Close.
Tip

Keep the Database Layout dialog box displayed while creating or updating queries as a reference to the database schema.

Update the SQLEditor Display

  1. Create a new statement or view an existing statement.
  2. In the appropriate dialog box, click Execute.
  3. When the statement runs without error, click Submit.

Reference

Use the following user-interface elements of SQLEditor to create and manage SQL statements in XLiRAD:

For information about dialog boxes presented when you work with SQLEditor, see:

SQLEditor Window

The SQLEditor window lists SQL commands stored on the server computer and displays:

The window also provides access to functions through toolbar buttons, window menus, and a shortcut menu.

Click to expand image

SQLEditor displays statements stored on the server at the time you start SQLEditor. If other users subsequently create new or modify existing statements on the server, you can update the SQLEditor window to display the latest set of statements by means of the Refresh SQL button or the Refresh List command on the Query menu.

Toolbar Buttons

Icon

ToolTip

Same as this command

sortbyID.gif

ID Sort

By ID Number on Sort menu

sortbyDB.gif

DB Sort

By Database Name on Sort menu

searchkeyword.gif

Keyword Search

Keyword Search on Sort menu

addquery.gif

New SQL

Add New Query on Query menu

updatequery.gif

Edit SQL

Update Query on Query menu

deletequery.gif

Delete SQL

Delete Query on Query menu

search.gif

Search Templates

Template Search on Query menu

refreshlist.gif

Refresh SQL

Refresh List on Query menu

dblayout.gif

DB Layout

Database Layout on Query menu

Shortcut Menu Commands

When you right-click a statement in the SQLEditor window, the following commands become available.

Option

Description

Clone

Creates a new statement identical to the one selected.

Copy

Copies the selection to the Windows Clipboard. You can paste it into another application or use it the copied data when working with other statements.

Update

Identical to the Update Query menu command and the Edit SQL toolbar button.

Delete

Identical to the Delete Query menu command and the Delete SQL toolbar button.

Menus

Menu name

Description

File menu

Use to close the SQLEditor window.

Sort menu

Use to modify the way that SQLEditor displays statements or to locate statements using search criteria.

Query menu

Use to add, modify, or delete SQL commands, find the templates that use a particular statement, update the display as statements change on the server, and view the tables and fields used in a particular database.

Menu Commands

File Menu

Command name

Description

Exit

Closes the SQLEditor window.

Sort Menu

By ID Number

Lists statements in numeric order by command ID.

By Database Name

Groups statements according to the database used.

Keyword Search

Highlights statements that contain a text string you define (does not support wild-card searches).

Remove Highlighting

When clicked, restores original display of listing before the search (without highlighting).

Query Menu

Add New Query

Displays the Command Editor dialog box where you define a statement "from scratch" or by means of the SQL Wizard.

Update Query

Displays the Command Editor dialog box where you can edit a statement.

Delete Query

Displays a dialog box where you can choose to delete a statement.

Template Search

Displays a window that shows the templates that include the selected statement.

Refresh List

Updates the listing with new statements available on the server, if any.

Database Layout

Displays the names of tables and fields in a database, along with field data such as record length and the acceptability of null values.

XLiRAD Client Login Dialog Box Help

Use the XLiRAD Client Login dialog box after you install SQLEditor or TemplateMaker and every time you start the program.

Option

Description

Server Name

Displays the name of the currently defined server computer. Type the name of your server or use the up or down arrow button to find the server name in the drop-down list box.

Server Port

Displays the currently defined port used for communicating with the DBServer installation.

Username

Type the user name assigned by your administrator.

Password

Type the password assigned by your administrator.

Cancel

Click this button to exit the dialog box without saving changes.

Test

Click this button to test the server port connection.

Submit

Click this button to save changes and complete the connection to the server.

Group Selection Dialog Box Help

Use the Group Selection dialog box to choose the SQL command group you want to use.

Option

Description

Group

Displays the groups available to the current user, in alphabetical order. Click the down arrow to search for additional groups available for the user.

Submit

Click this button to communicate the selection to the server and to display the SQLEditor window.

Cancel

Click this button to exit the dialog box.

Command Editor Dialog Box Help

Use the Command Editor dialog box to create a new statement in SQLEditor either manually or using the SQL Wizard.
Construction

SQL Statement

Displays the text of the existing statement. Change the text as appropriate.

Command ID

Contains the number that identifies this statement. Type a new number for this statement.

Add Form Data

Click this button to display the Form Variable Specification dialog box to specify variable names and types that the user can submit in a form on the HTML page.

SQL Wizard

Click this button to start the SQL Wizard.

Database

Displays the database queried by this statement. Use the up or down arrows in this list box to change the database name as appropriate.

Testing

Field

Displays the name of a field contained in the statement.

Value

Contains the value you want to assign to the field in the statement.

Query Output

Displays test results or error messages.

Refresh

Click this button to restore the statement saved on the server and overwrite manual entries.

Execute

Click this button to run the statement with the test data.

Cancel

Click this button to discard changes and restore the existing statement.

Submit

Click this button to save the changes to the statement.

Form Variable Specification Dialog Box Help

Use the Form Variable Specification dialog box to specify in a SQL statement the data that a user can submit in a form on the HTML page.

Option

Description

Variable Name

Type the name of the variable that identifies data you want to retrieve from or post to the database in the SQL statement.

Variable Type

Use the up or down arrows to find the type for the variable as appropriate. The options available depend on the variable types supported in the database.

Cancel

Click this button to discard changes and close the dialog box.

Database Layout Window Help

Use the Database Layout window to view the tables and fields in a database. This information is useful in working with SQL statements.

Option

Description

Database

Displays the database for the selected statement. Use the up or down arrows to find a different database.

Tables

Displays the tables defined in the selected database.

Field

Displays the fields defined in the selected database.

Type

Displays the type of values supported in this table field.

Length

Displays the length of this table field.

Number

Displays 0 if this table field does not support a null value or 1 if it does.