Functions - syntax, PL-SQL Programming

Functions

The function is a subprogram which can take parameters and be invoked. Normally, you can use a function to calculate a value. The function has 2 sections: the specification & the body. The specification starts with the keyword FUNCTION and ends with the RETURN clause that specifies the datatype of the result value.

The Parameter declarations are non-compulsory. The Functions which take no parameters are written without the parentheses. The function body starts with the keyword IS and ends with the keyword END followed by an elective function name.

The function body has 3 sections: an optional declarative section, an executable section, & an optional exception-handling section. The declarative section contains the declarations of the types, constants, cursors, variables, exceptions, & subprograms. These items are local and cease to exist whenever you exit the function. The executable section contains the statements that assign values, manipulate Oracle data, and control execution. The exception-handling section contains the exception handlers that deal with exceptions raised during the execution.

Syntax:

1438_functions.png

1737_functions 1.png

Posted Date: 10/8/2012 6:51:08 AM | Location : United States







Related Discussions:- Functions - syntax, Assignment Help, Ask Question on Functions - syntax, Get Answer, Expert's Help, Functions - syntax Discussions

Write discussion on Functions - syntax
Your posts are moderated
Related Questions
Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

IN Operator The operator IN tests the set membership. This means "equal to any member of." The set may have nulls, but they are ignored. For illustration, the statement below do

what is the use of declare keyword

Datatypes Every constant and variable has a datatype that specifies the storage format, constraints, and the valid range of values. The PL/SQL gives a variety of predefined dat

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_d

Positional Notation The first procedure call uses the positional notation. The PL/SQL compiler relates the first actual parameter, account, with the first proper parameter, ac

Type versus Representation Confusion in SQL This describes how a value might have two or more distinct representations. For example, user-defined type POINT might have a decla

Project Description: I want a database for large governmental and private data sets on one country that will be easily extended to other countries in the future. Also, the datab

Renaming Columns - SQL SQL has no direct counterpart of RENAME. To derive the table on the right in Figure 4.4 from the table on the left, Tutorial D has IS_CALLED RENAME ( St

Using RENAME in combination with JOIN - SQL Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent ex