Previous Next JavaScript must be enabled to correctly display this content

## 3.10 Managing Functions

A function is a subprogram that can take parameters and return a single value. You can use Object Browser to create, view, edit, compile, download, and drop functions.

- Creating a Function
  Create a function using Object Browser.
- Viewing a Function
  Select a function from the Object Tree and access tabs in the Object Detail View.
- Editing a Function
  Select a trigger from the Object Tree.
- Compiling a Function
  Select a function from the Object Tree and click Save and Compile.
- Downloading a Function
  Select a function from the Object Tree and click Download to save the function.
- Dropping a Function
  Select a function from the Object Tree and click Drop.

See Also:

- Oracle AI Database SQL Language Reference for information about PL/SQL functions
- Oracle AI Database PL/SQL Language Reference

Parent topic: Managing Database Objects with Object Browser

### 3.10.1 Creating a Function

Create a function using Object Browser.

To create a function:

1. In Object Browser, click the Create Database Objects menu and select Function.

   Tip:

   To create new objects from the Object Tree, right-click the object and select the Create option.

   The Create Function Wizard appears.

2. On Create Function:
   1. Name - Enter the name of the function. This name must conform to Oracle naming conventions and cannot contain spaces or start with a number or underscore.
   2. Include Sample Code - Specify whether to include sample code.
3. Click Create Function.

Parent topic: Managing Functions

### 3.10.2 Viewing a Function

Select a function from the Object Tree and access tabs in the Object Detail View.

To view a function:

1. In Object Browser, Object Tree, expand Functions and select a function.
2. The Object Detail View appears and displays four tabs:
   - Code - View the source code for the function, or edit it manually. Available actions include:
     - Download
     - Save and Compile
     - Drop
     - Refresh
   - Dependencies - View objects that use (or depend) on the current function and objects that the function depends on. Select the Refresh button to refresh the list of functions.
   - Errors - View the errors related to the current function. Select the Refresh button to refresh the list of functions.
   - Grants - View the details of grants for the current function. Available buttons include:
     - Grant
     - Revoke
     - Refresh

Parent topic: Managing Functions

### 3.10.3 Editing a Function

Select a trigger from the Object Tree.

1. In Object Browser, Object Tree, expand Functions and select a trigger.
   The Object Detail View appears.
2. In the Code tab, edit the code. Other edit controls include:
   - Undo
   - Redo
   - Find
   - Auto Complete

   Tip:

   To learn more about the Code Editor, see Code Editor in Object Browser.
3. Select Save and Compile to save your changes.

Parent topic: Managing Functions

### 3.10.4 Compiling a Function

Select a function from the Object Tree and click Save and Compile.

If you edit and make changes to a function, you must compile to save your changes. Compiling re-creates the function in the database.

To compile a function in Object Browser:

1. In Object Browser, Object Tree, expand Functions and select a function.
   The Object Detail View appears.
2. On the Code tab, click Save and Compile.
   If the compilation fails, an error message displays. Correct the error and compile the function again.

Parent topic: Managing Functions

### 3.10.5 Downloading a Function

Select a function from the Object Tree and click Download to save the function.

To download a function:

1. In Object Browser, Object Tree, expand Functions and select a function.
   The Object Details View appears.
2. On the Code tab, click Download.
3. Enter a file name for the file and click Save.
   The file saves in `.sql` format.

Parent topic: Managing Functions

### 3.10.6 Dropping a Function

Select a function from the Object Tree and click Drop.

To drop a function in Object Browser:

1. In Object Browser, Object Tree, expand Functions and select a function.
   The Object Details View appears.
2. On the Code tab, click Drop.
   1. Drop - Review the details.
   2. SQL - Displays the SQL generated to drop the function. To copy the displayed SQL, click the Copy icon.
   3. To confirm your selection, click Drop again.
3. To confirm, click Drop.

Parent topic: Managing Functions