Creating queries

The Content Explorer allows you to create queries in a convenient graphical environment. Little or no SQL knowledge is required.

NoteYou can only use the Content Explorer to generate ad hoc queries, which cannot be saved to a file or to the repository. However, if you want to save the generated SQL for other purposes, you can copy it from the Generated Query window that can be opened by selecting Generated Query from the View menu. To do so, select the part of the generated query and copy it to the clipboard.

StepsTo create a simple query

The following procedure uses the PRODUCTS table to generate a simple query that retrieves all attributes from the a table.

  1. Click the table or view name in the Navigation area.

  2. Drag the selected object to the Design area.

  3. Verify the results of the generated query by clicking View the Generated Query.

StepsTo create a query using multiple tables

The following procedure uses the PRODUCTS and the SALES table to generate a query that retrieves joined information from two tables.

  1. Click the table PRODUCTS and drag it onto the Design area.

  2. Click the table SALES and drag it onto the Design area.

  3. Create a join between the tables by drawing a link between the fields PR_ID of both tables. The join can also be automatically created if you select the Auto Join Generation option in the Preferences.

StepsTo use the Auto Join Generation option

Auto Join Generation is based on identical attribute names used within tables or views. If there are identical names and the Auto Join Generation option is selected, the Query Designer automatically creates a join based on those attributes.

  1. Access the Preferences dialog box by selecting Preferences from the File menu.

  2. Select the Workbench | Query Designer | Auto Join Generation check box in the Preferences dialog box.

StepsTo modify the default setting of a join

A join between two tables is indicated by a line that connects the joining fields. The line is labeled with a join operator. The default is Equi Join.

  1. Right-click the line connecting the two joining fields.

  2. Select the Modify command.

  3. Choose a join type from the list:

    • =      EQUI Join

    • +=    Left outer Join

    • =+    Right outer Join

    • +=+ Full outer Join

    The default setting of the join changes to the type you selected.

StepsTo add one attribute to the SELECT clause

  1. Drag the tables to the Design area (if they are not there already).

  2. Click the attribute names you want to add.

  3. Right-click and select Add Items to Selection.

StepsTo select more than one attribute to the SELECT clause

  1. Drag the tables to the design area (if they are not there already).

  2. Hold the Ctrl key and click the attributes that you want to add to the SELECT clause.

  3. Right-click and select the Add Items to Selection.

StepsTo select all attributes of a selected table to the SELECT clause

  1. Click the header (name) of the table in the Design area.

  2. Right-click and select Add Items to Select.

StepsTo view generated SQL statements

  1. To display the statement as currently generated by the Content Explorer, click Generated Query or select Generated Query from the View menu.

StepsTo add functions to the SELECT attributes

  1. Click the attribute and right-click to open the pop-up menu.

  2. Select any of the available functions.