PL / SQL Developer 6 Template Using Series Documents (2)
Template Format Design Application Guide (Translation)
Create and modify templates
To modify the already existing template, select the template you want to modify and click the right button to open the shortcut menu. This will open the text editor of the display template content. The text contains complete template content, including variables, queries, etc. The following section describes the detailed format of the template text.
To create a new template, right click on the folder you want to create, select [New Template] from the shortcut menu. You first want to enter the name of the template and then pop up the template editor. You can also create a new folder through the [New Folder] menu.
Template text
Template text includes text and variables. Text can not pass any modifications to a simple copy to the source file. Take a template that contains only text "commit;" Template named commit as an example, double-click the template, commit; this text will be inserted directly into the original cursor position. In the template, it is included in the scratches (see below), so if you want to make a text, use two middle brackets, for example: [Option]]
Custom variable
The variable code in the template text will be replaced by text, which can be a fixed value, like the current date or the current username, or something specially defined. When the template is called, these user variables are displayed on the open form. Here is an example of defining a variable name [Name] and type [type] function template:
Create Or Replace Function [Name] Return [Type] IS
Begin
Return (Result);
END [NAME];
When the template is called, the user can assume a specific value to both variables of Name and Type. As you can see, the Name variable is used twice, and the user will only be prompted once and is replaced with the same value.
l Default
The default value defined for variables can be placed behind the variable name. You can define varchar2 by default type using the following description is the default function type Function Type:
[Type = varchar2]
l fixed list
For some variables with a fixed value list, you can define its selection list values. For example: To limit the Function variable type type Type is VARCHAR2, NUMBER, and DATE, you can define it below:
[Type = varchar2, * number, date]
The first list value with an asterisk represents the list default
l Optional list
For variables to be supplied to the user, the variables of other values are allowed, and the last increase of the list ... this value.
[Type = varchar2, number, date, ...]
l Specific list
To replace the list content with text, you can define text for each list, just like the following example, describe the text plus colon plus value:
[Level = Write No Database State: WNPS, Read no Database State: rnds, ...]
l check box
Variables selected by true and false values You can define them with a checkbox. Place a slash / in the middle of the two values, the left side of the slash indicates the value of the unselected, and the right side represents the selected value. The following variable indicates that the text for Each Row will be inserted when the check box is not selected, and the text for Each Statement will be inserted after the check box is selected.
[Statement level? = For Each Row / for Each Statement]
If your text contains special characters (such as Comma's, Brackets, And So ON), you can enclose them with parentheses. Below is a template example of creating a trigger TRIGGER using a user-defined variable. Create or Replace Trigger [name]
[Fires = Before, After, Instead of] [Event = INSERT, UPDATE, DELETE, ...]
ON [Table or View]
[Statement level? = For Each Row / for Each Statement]
Declare
- Local Variables Here
BEGIN
END [NAME];
Tip You can create multiple program units in a template with a slope separator separated by a slope. In this way you can create a template in a program file for some formats.
When using this template, the user will pop up the dialog box prompt to enter the value of the variable:
Fixed variable
In addition to user-defined variables, you can also use fixed variables. These texts used to replace variables are not defined by the user, but are defined by the system (Date, UserName) or template developer (queries, text).
l system variable
The following is the four system variables defined
$ OSUSER operating system username
$ DBUSER Currently logged in database users
$ Date Current Date
$ TIME Current Time
The first two lines of the following example will insert the user of the operating system and the current date time to the source file:
- Author: $ 斯 osSER
- Created: $ date $ time
- Purpose: [Purpose]
Procedure [name] IS
Begin
;
END [NAME];
Note that the system variable does not use parentheses in the template text, but you need to add $ symbols in front.
If you don't want to use system variables, but to apply the original text of the system variable, you can add the second $ symbol in front of the text. E.g:
- $$ Date $ $ REVISION $
The result came out will be $ DATE $ Revision $.
l cursor position
The cursor position variable will define the positioning of the cursor after the template text is inserted into the editor. Just place [#] to the desired location:
loop
[#]
End loop;
l query variable
You can use queries to generate a list of templates. The following example defines a query variable SEQ_QUERY, then applied to the optional list of sequence variables:
[$ Query seq_query =
SELECT LOWER (Object_name) from user_Objects
Where object_type = 'sequence'
Order by Object_name]
Select [sequence = $ seq_query, ...]. NextVal Into [variable name] from dual;
Sequence is an optional list, because the text is added later, ... "means that the user can manually enter other values. The query result set can be simply considered to be separated by a comma.
l Contains and removes the text
You can include and remove the text of the template through another variable. In the following example, when the user enters the value of the search condition (SEARCH CONDition), the WHERE character will be automatically added.
SELECT [ITEM LIST]
INTO [Variable List]
From [Table List]
[ Search Condition = where] [search condition];
As a result, users do not have to type 'where' text in Query Condition [Search Condition]. To remove a piece of text, you can change the " variable name" to "- Variable Name". l text variable
You can define text variables in the template and use these variables in other parts of the template. If you want to have a large piece of text, it is very useful. In the following example, an error processing block can be included according to the user needs.
[$ Text exception_block =
EXCEPTION
When no_data_found the ...
WHEN TOO_MANY_ROWS THEN ...
When Others the ...
End;]
SELECT [ITEM LIST]
From [Table List]
INTO [Variable List]
Where [search conputing];
[EXCEPTION block = / $ exception_block]
Template icon
Set an icon in each template in the tree list of the template window. The template window will find the same bitmap file as the template file name. Such as template cursor.tp, if present, it will use the Cursor.bmp bitmap under the same folder, if the bitmap does not exist, it will look for the Cursor.bmp file under the current directory subdirectory. If this bitmap is still not, it will look for the current directory and subdirectories' default.bmp file.
The template icon must be a bitmap of 16 * 16-size 16-color.
Yasheng (translation)
2005-03-23