Use Visual SQL to create select, insert, update, and delete statements from source code in SQL File Editor, SQL Scrapbook, and the Source page of the procedural object editors.
Open a SQL File Editor or SQL Scrapbook session, or open a procedural object in the Source page of the corresponding editor.
The Visual SQL dialog displays each table and its columns. If you are modifying an existing SQL statement, the Visual SQL dialog displays the appropriate tables and columns without first presenting a Select Tables dialog.
What you can enter depends on the which SQL statement type you are inserting.
Option | Action |
---|---|
select | Choose those columns that you want selected. You can define Where/Having conditions, choose Sort columns, add Compute columns, and so on. |
insert | In the appropriate column fields, enter the column values you want to insert. You can type in literal values, choose arguments from the editor, or click the Select button to invoke Visual SQL again and create a select statement to fill in insert column values. Click OK to close the Insert Column Values dialog. |
update | In the Update Column Values dialog, choose the columns you want updated from the list of columns below, and enter values in the Value field. You can enter literal values, select arguments from the editor, or build expressions using the logical operator buttons. Click OK to close Update Column Values. You can proceed to define any Where conditions to specify the rows affected by the update. |
delete | Using the menus on the Where tab, define one or more conditions that identify the rows to be deleted. |
While developing your SQL statement, the SQL code to be generated appears under the Preview tab in the the lower half of Visual SQL. You can still add clauses to the statement by using the tabs under the bottom half of the Visual SQL dialog. When you close Visual SQL, the code is inserted into the editor from which you invoked Visual SQL.
Clause | Description |
---|---|
Where | Determines the rows to be affected for select, update, and delete statements. |
Sort | Allows you to sort query results by columns in either ascending or descending order. |
Group | Organizes query results into groups based on repeating values in grouping columns. |
Having | Used to display or reject rows defined by the group clause, excluding rows that do not meet the search conditions of that clause. |
Computer | Allows you to define additional result columns using expressions; when used with a group clause, these expressions can calculate summary values. |
For example, selecting the Where tab displays input fields containing Column, Operator, Value, and Logical columns. Click the right end of a Column, Operator, or Logical column to display the drop-down list that shows the available options from which to select. Enter the value in the Value column. If there are existing local variables or parameters, you can right-click the Value column and select Argument to choose an existing variable or parameter.
Drop-down lists are available for columns and operators for the Where and Having clauses. After you enter a value into the Values column, context menus provide the following options for the Where, Having, and Compute clauses.
Option | Description |
---|---|
Columns | Menu of columns to paste. |
Functions | Database-specific functions. |
Arguments | Parameters and variables. |
Value | List of column values (enabled only if a column is specified). |
Select | Invokes Visual SQL again so you can define a subquery or nested select. |
Messaging (ASE) | Invokes Messaging wizard; helps you define a function, which can be used like any other database-specific function, by itself or as part of an expression. |
From the context menus, you can also clear a clause of its current values by choosing the Clear option, or you can insert or delete a clause by choosing Insert Clause or Delete Clause, respectively.
Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com
Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.