Creating a Query File

Create a query (.qry) file to add a SQL statement operation to a database service. A query file contains Select statements created by the SQL Query Editor and can be reused for other database services at any time.

To create a query file:

  1. Create a query file. Do the following:

    1. From the main menu bar, select File|New|Other.

      The Select a wizard dialog appears.

    2. Select Sybase|Query, and click Next.

      The Create Query File dialog appears.

    3. Specify the name and location of the query file. Do the following:

      • Select the project to contain the query file.

      • Name the file.

    4. Select a database connection profile for the query file. Choose from the following:

      • Click Connect to connect to the database.

      • If no connection profile is appropriate for the query file, click New Connection Profile to create a new one.

      • Click Finish to create the file.

      The SQL Query editor opens displaying a list of database tables.

  2. Create more complex SQL statements by adding and nesting clauses. Do the following:

    1. Select the query file you want to include nesting and click Open With|SQL Query editor in the context menu.

    2. Define the table layout. Select the columns in the list that you want to use in your table and specify the following clauses:

      Available Clauses in Visual SQL

      ClauseDescription

      Where

      Specify the rows to be affected by a select statement. Choose from the following:

      • Column

      • Operator

      • Value

      • Logical

      Compute

      Define additional result columns using expressions. If used with a group clause, these expressions may calculate a Summary value.

      Sort

      Sort queries by column in ascending or descending order.

      Group

      Organize groups based on repeating values in the grouping columns. Drag and drop groups from the left pane to the right pane.

      Having

      Specify which groups to display based on the group clause. Rows that do not meet the search conditions of that clause are excluded

      XML

      Currently not supported.

    3. (Optional) Preview the query and retrieval arguments:

      • Preview the query. Click inside the SQL editor and select Design|Preview from the main menu bar.

      • Add the retrieval arguments:

        1. Click inside the SQL editor and select Design|Retrieval Arguments from the main menu bar to open the Specify Retrieval Arguments dialog.

        2. Enter the argument name, select an argument type from the drop-down list, and click OK.

          The argument is now available for use.

          See Specifying Retrieval Arguments in a Query File for more information.

    4. Save the query file. Select File|Save from the main menu bar.

Adding a SQL Statement Operation by Importing Query Files

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com