Using an Intelligent Template

Select an intelligent template to enter predefined SQL code, including automatically determined table columns, into a SQL file or procedural object at the desired location.

Intelligent templates eliminate the need to manually enter column names in SQL File Editor by automatically presenting table columns for a given table name. Intelligent templates come in two options:

Option Description
With declared variables

Automatically populates the column names and the where clause. It uses the primary key or the check constraint for the where clause condition.

It also adds the query within a begin-end block so that the primary key or the check constraint variables defined are local to the query.

 
BEGIN 
DECLARE @PK_au_id_var id
SELECT @PK_au_id_var = 10001
SELECT au_id, au_lname, au_fname, phone, address,
city, state, country, postalcode
FROM authors
WHERE au_id = @PK_au_id_var
END 
Without declared variables

Automatically populates the column names and the where clause. It uses the primary key or the check constraint for the where clause condition, but does not declare the primary key or check constaint local variables.

SELECT au_id,
au_lname, au_fname, phone, address, city, state, country,
postalcode
FROM authors
WHERE au_id = 10001
  1. In the editor, position the cursor where you want to insert an intelligent template.
  2. Open Content Assist by pressing the Content-Assist key sequence.

    The default is Ctrl+Space.

    Templates appear in the options list with other syntax proposals.

    Note: User-defined datatypes are listed with the original system types on which they are based enclosed within brackets. For example, a user-defined type named mytype1 based on DECIMAL(6, 2) would be listed as mytype1 [DECIMAL(6, 2)].
  3. Select and double-click the intelligent template you want to insert.

    You can also navigate the Content-Assist list using the Up or Down arrow key until you find the template.

  4. Enter a table name, or use the Content-Assist key sequence, and select a table from the generated list.

    To use an intelligent template for an object that is not owned by dbo, enter the owner with the object name. For example, for the employee table owned by guest, enter guest.employee.

  5. Press Enter.

    To display the owner of an object that is not owned by dbo, you must set the Show Owner of Table or View property in the SQL Editor Code Assist preferences page.

    The editor lists columns for the specified table in the SQL code.

  6. Enter values in the placeholders.
    • If you have selected an intelligent template with declared variables, provide values for the variables that have been declared in the inserted template code.
    • If you have selected an intelligent template without declared variables, provide values for the corresponding value placeholders.
    Press Tab to move the cursor to the next unique variable. Press Shift+Tab to move the cursor to the previous unique variable.
Related concepts
Content Assist
SQL Templates
Intelligent Templates
Related tasks
Inserting Predefined SQL Code Using a Template
Creating a New Template
Related reference
Code Assist Preferences

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.