Pl/sql DEVELOPER 6 Template Format Design application guide (original translation)

Source: Internet
Author: User
Tags date format define end include sql variables variable
templates | design
Pl/sql DEVELOPER 6 template using series documents (II)







Template Format Design application Guide (translate)















Creating and modifying templates







To modify a template that already exists, select the template you want to modify right-click to open the shortcut menu. This opens a text editor that displays the contents of the template. The text contains the complete template content, including variables, queries, and so on. The detailed format of the template text is described in the following sections.







To create a new template, right-click the folder you want to create, and choose New Template from the shortcut menu. You first enter the name of the template, and then the template editor pops up. You can also create a new folder by using the [New Folder] menu.







Template text







Template text includes text and variables. Text can be copied to the source file without any modification. Take one contains only the text "commit;" As an example of a template named Commit, after double-clicking the template, commit; The text will be inserted directly into the original cursor position. Expressed as a variable in parentheses in the template (see below), so if you want to use the brackets as a text, replace with two brackets, for example: [[option]]







Custom variables







The variable code in the template text is replaced with text that can be a fixed value, such as the current date or current username, or something specifically defined by the user. These user variables appear on the open form when the template is called. Here is an example that defines the variable name [name] and type [form] function Template:







Create or Replace function [Name] return [Type] is







Begin







return (result);







end [Name];







When a template is invoked, the user can assign a specific value to both the name and type variables. As you can see, the name variable is used two times and the user will be prompted only once and replaced with the same value.







L Default Value







The default values defined for a variable can be simply placed behind the variable name. You can use the following description to define VARCHAR2 as the default function type:







[Type = varchar2]







L fixed List







For some variables that have a fixed list of values, you can define their picklist values. For example, to restrict the variable type of a function to VARCHAR2, number, and date, you can define the following method:







[Type = Varchar2, *number, Date]







The first list value with an asterisk indicates the default value of the list







L Optional List







For variables that you want to provide to the user for a column selection, and allow other values to be entered at the end of the list ... This value can be.







[Type = varchar2, number, date, ...]







L can describe the list







To replace the list with text, you can define descriptive text for each list, as in the following example, the description text plus a colon plus a value:







[level = Write No database State:wnps, Read No database state:rnds, ...]







L check box







The variables you choose for the true or false value can be defined with a check box. Place a slash/in the middle of two values, the left side of the slash indicates the value when unchecked, and the right indicates the selected value. The following variable indicates that the text is inserted for each row when the check box is not selected, and the text is inserted for each statement when 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 in parentheses. The following is an example of a template that uses user-defined variables to create a trigger trigger.







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







Begin







end [Name];







Tip, you can create multiple program units in a single template by using a slash delimiter-delimited method. In this way you can create a template in a program file for some format.







When you use this template, the user will pop up the dialog box as shown below to prompt for the value of the variable:



















Fixed variable







In addition to user-defined variables you can also attach the use of fixed variables. The text used to displace variables is not defined by the user, but by the system (date, username) or by the template developer (queries, text).







L System Variables







The following are 4 system variables defined







$OSUSER the user name of the operating system







$DBUSER the user who is currently logged on to the database







$DATE Current Date







$TIME Current Time







The first two lines of the following example are inserted into the user of the operating system and the current date time to the source file:







--Author: $OSUSER







--Created: $DATE $TIME







--Purpose: [Purpose]







procedure [Name] is







Begin







;







end [Name];







Note The system variable does not use brackets in the template text, but it needs to be preceded by the $ symbol.







If you do not want to use system variables, but to apply the original text of the system variable, you can add the second $ symbol to the front of the text. For example:







--$ $Date $ $Revision $







The resulting text will be $date$ $Revision $.







L Cursor Position







The cursor position variable defines the positioning of the cursor when the template text is inserted into the editor. Just place [#] where you want to be:







Loop







[#]







End Loop;







L Query variables







You can use queries to generate list values for a template. The following example defines a query variable seq_query and then applies to an 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 appended to it, meaning that the user can manually enter other values. The query result set can be simply viewed as a comma-delimited list value.







L contains and removes text







You can use another variable to include and remove text from the template. In the following example, the where character is automatically added when the user enters the value of the query criteria (search condition).







Select [Item list]







into [Variable list]







From [Table list]







[+search Condition=where] [Search condition];







The result is that the user does not have to type ' where ' text in the query criteria [search condition]. To remove a piece of text, change the "+ variable name" to "-variable name."







L Text Variable







You can define text variables in the template and use them in other parts of the template. This is useful if you want to include a large chunk of text in a selection. In the following example, you can include an error-handling block based on the user's needs.







[$TEXT exception_block=







exception







When No_data_found then ...







When Too_many_rows then ...







When others then ...







End;]







Select [Item list]







From [Table list]







into [Variable list]







where [Search condition];







[Exception block =/$exception _block]







Template icon







Each template displays an icon in the tree List of the template window. The template window looks for the same bitmap file as the template file name. If the template is CURSOR.TP, it will use the Cursor.bmp bitmap under the same folder, and if the bitmap does not exist, it will look for the cursor.bmp file in the current directory subdirectory. If this bitmap is still not present, it will look for the default.bmp files for the current directory and subdirectories.







Bitmap for the template icon must be a 16-color 16*16 size.























Ye Zhengxing (translation)







2005-03-23
























Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.