Minggu, 07 September 2008

Creating a program

To create a new program, press the New button on the toolbar and select the Program Window item and, for example, the Function sub item. You are now prompted for various variables that are relevant to this program type. In this case, where we are creating a function, the name of the function, the parameter list, and its return type:


As the title of this dialog suggests, this information comes from a template. PL/SQL Developer provides several standard templates, which you can modify as needed. You can also define new templates. Information about defining templates is provided in Templates.

After you have entered the variables and pressed the OK button, a Program Editor Window appears with a template function in it. Each program you create in the Program Editor unit must start with the familiar 'create or replace' SQL syntax. In this case we are creating a function 'even', and the source file could look like this:

At the left side of the editor you see the Code Contents, which displays variables, constants, types, exceptions and local functions and procedures of the program unit. This is useful for large program units such as package bodies and type bodies. This feature is described in detail in Code Contents.

A program file can contain more than one program unit. By right clicking in the Program Editor, a popup menu appears that allows you to add or delete a program unit. You can switch between the program units by selecting the appropriate tab at the top oft the window. This way you can conveniently keep related program units together in one source file. A package specification and body are a good example of this feature.
A program unit should be positioned after any other program unit in the program file it might reference. If you create a function 'odd' that references the previously created function 'even', the program editor should look like this:

From PL/SQL Developer Help

Tidak ada komentar: