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
Data Types in SQL SQL's concept does not differ significantly from that defined in the theory book, apart from that business concerning NULL. However, the theory book equates

Declaring Records Whenever you define a RECORD type, you may declare records of that type, as the illustration shows: DECLARE TYPE StockItem IS RECORD ( item_no INTEG

Use the RETURNING Clause Frequently, the application requires information about the row affected by a SQL operation, for illustration, to produce a report or take a subsequent

Question: (a) In the context of database security explain how the following database features help to enforce security in the database system: (i) Authorisation (ii) Access

User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai

ROWNUM The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of

SQL outer join SELECT * FROM IS_CALLED NATURAL LEFT JOIN IS_ENROLLED_ON Note that adding LEFT to an invocation of CROSS JOIN has no effect unless the right-hand operand

INSERT Statement The INSERT statement adds fresh rows of data to the specified database table or view. Syntax:

%ROWCOUNT When its cursor or cursor variable is opened, the %ROWCOUNT is zeroed. Before the first fetch, the %ROWCOUNT yields 0. Afterward, it yields the number of rows fetche

SQL Is a Database Language: The commands given to a DBMS by an application are written in the database language of the DBMS. The term data sublanguage is sometimes used instea