Declaring objects in pl/sql, PL-SQL Programming

Declaring Objects:

You can use the object types wherever built-in types like CHAR or NUMBER can be used. In the block below, you can declare object r of type Rational. Then, you can call the constructor for the object type Rational to initialize the object. The calls assign the values 6 & 8 to attributes num and den, correspondingly.

DECLARE

r Rational;

BEGIN

r := Rational(6, 8);

DBMS_OUTPUT.PUT_LINE(r.num); -- prints 6

You can declare objects as the formal parameters of the functions and procedures. In that way, you can pass objects to the stored subprograms and from one subprogram to the other. In the later illustration, you use the object type Account to specify the datatype of a formal parameter:

DECLARE

...

PROCEDURE open_acct (new_acct IN OUT Account) IS ...

In the illustration below, you can use object type Account to specify the return type of the function:

DECLARE

...

FUNCTION get_acct (acct_id IN INTEGER) RETURN Account IS ...

 

Posted Date: 10/6/2012 8:11:34 AM | Location : United States







Related Discussions:- Declaring objects in pl/sql, Assignment Help, Ask Question on Declaring objects in pl/sql, Get Answer, Expert's Help, Declaring objects in pl/sql Discussions

Write discussion on Declaring objects in pl/sql
Your posts are moderated
Related Questions
Transaction Control The Oracle is transaction oriented; that is, Oracle uses the transactions to make sure the data integrity. The transaction is a sequence of SQL data manip

Advantages of Wrapping   The PL/SQL Wrapper convert the PL/SQL source code into a transitional form of the object code. By hiding the application internals, the Wrapper secure

Keyword and Parameter Description: table_reference: This specifies a table or view that should be accessible when you execute the DELETE statement, and for that you must

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

EXIT-WHEN The EXIT-WHEN statement permits a loop to complete conditionally. Whenever the EXIT statement is encountered, the condition in the WHEN clause is computed. When the co

Example of GROUP BY and COLLECT Operator Example: Using GROUP BY and COLLECT to obtain C_ER2 SELECT CourseId, CAST ( COLLECT (ROW (StudentId, Mark)) AS ROW (Studen

Using LIMIT For nested tables, that have no maximum size, the LIMIT returns NULL. For varrays, the LIMIT returns the maximum number of elements that a varray can have (that yo

Use of COUNT in SQL It describes and discusses various general methods of expressing constraints, eventually noting that support for "=" with relation operands is sufficient f

Manipulating Individual Elements Faraway you have manipulated an entire collection. Within the SQL, to manipulate the individual elements of the collection, and then use the ope

Keyword & Parameter Description: WHEN: This keyword introduces the exception handler. You can have many exceptions execute the similar sequence of the statements by follo