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
Using raise_application_error The Package DBMS_STANDARD that is supplied with Oracle gives language facilities that help your application to interact with Oracle. For illustra

Mixed Notation The fourth procedure call shows that you can mix the positional and named notation. In this situation, the first parameter uses the positional notation, & the s

Use the MASCOT tables CREDITRS, PORDS and PAYMENTS to write SQL queries to solve the following business problems. These tables / data are available to you via the USQ Oracle server

IN OUT Mode An IN OUT parameter passes initial values to the subprogram being called and return efficient values to the caller. Within the subprogram, an IN OUT parameter acts

Restriction in SQL Syntax: SELECT DISTINCT StudentId FROM IS_CALLED WHERE Name = 'Boris' The WHERE clause operates on the result of the FROM clause in analogo

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

SQLs counterpart of the key words: The text from the opening parenthesis to the end of the fourth line specifies the declared type of the table, meaning that every table ever

Fetching from a Cursor Variable The FETCH statement retrieve rows one at a time from the product set of a multi-row query. The syntax for the same is as shown: FETCH {curso

Cursors   To execute the multi-row query, the Oracle opens an unnamed work region which stores the processing information. The cursor names the work region, access the informa

PITS Depressions in secondary cell wall is called pit. A pit present on the free cell wall surface without its partner is called Blind pit. It consists of 2 parts -