Previous Topic: Step 2: Identify the QueryNext Topic: Step 4: Using SQL Keywords


Step 3: Use the SQL Template

This section describes how to display the SQL Template and copy syntax from it to the EDITOR panel to create a customized template for a query. After displaying the EDITOR panel in Create Mode and identifying a new query, you can begin creating the query.

In this step you learn how to display the SQL Template and copy needed syntax from it to the EDITOR panel.

Entries

The following describes the steps required to display and copy syntax to an EDITOR panel in Create Mode.

Step 1

On the EDITOR panel (Create Mode), move the cursor to the first position in the text entry area.

Step 2

Press <PF9> TEMPLATE.

Step 3

View the Query Template (DQD50) panel shown below:

=> Place a nonblank beside each statement that is to be included in the query --------------------------------------------------------------------------DQD50 DATAQUERY: QUERY TEMPLATE ------------------------------------------------------------------------------- Lower case words represent entries which must be replaced by the user. Parentheses indicate optional entries: these may be included by removing the parentheses only or deleted by removing both the parentheses and data. ------------------------------------------------------------------------------- _ SELECT column1, column2, count(column3) _ FROM table1, table2 _ WHERE table1.column1 = table2.column2 and column3 > 0 _ GROUP BY column1, column2 _ ORDER BY column1 ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> NOT USED <PF4> NOT USED <PF5> NOT USED <PF6> NOT USED <PF7> BACKWARD <PF8> FORWARD

Step 4

Place a character in the field preceding each keyword needed for the new query.

Step 5

Press <PF2> RETURN.

Result

The following sample shows how the EDITOR (DQD10) panel looks when syntax is copied from the SQL Template panel.

=> --------------------------------------------------------------------------DQD10 DATAQUERY: EDITOR CURRENT TABLE: ________________________________ ------------------------------------------------------------------------------- NAME: SQLSAMPLE01 TYPE: SQL STATUS: PUBLIC DESCRIPTION: SAMPLE BASIC QUERY__________________________________________ ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+. .. ================================ T O P ===================================== 01 SELECT column1, column2, count(column3) 02 FROM table1, table2 03 WHERE table1.column1 = table2.column2 and column3 > 0 04 ORDER BY column1 .. =========================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> DISPLAY COLUMNS <PF4> DISPLAY KEYS <PF5> DISPLAY ALL <PF6> LIST TABLES <PF7> BACKWARD <PF8> FORWARD <PF9> TEMPLATE <PF10> VALIDATE <PF11> RIGHT/LEFT <PF12> PROCESS MODE

Options

The following is a guide to other things you could do when you use the SQL Template.

Look at the syntax

You can choose to use the Template only as a help panel by not entering anything in the fields on the template.

Copy one clause at a time

You can access the Template as many times as you like and copy each clause separately, where and when you decide you need it.

Do not use the template

You can simply type your query in the text entry area without displaying the template.