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
Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.

Usefulness of Data Type In SQL, as in most computer languages, a type can be used for constraining the values that are permitted to be used for some purpose. In particular, i


CLOSE Statement The CLOSE statement allows the resources held by a cursor variable or open cursor to be reused. No more rows can be fetched from the cursor variable or closed

Using Aggregation on Nested Tables Example is the most direct translation of its counterpart in the theory book that can be obtained in SQL but it is so over-elaborate that no

SSRS Report Writing Project Description: This report is part of a larger project to make a SQL Server Reporting Service (SSRS) based reporting solution. There can be more rep

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean's wants to create a trigger that automatically updates the stock level of all pr

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

Using Subqueries A subquery is a query (typically enclosed by parentheses) that appears within another SQL data manipulation statement. If evaluated, the subquery gives a va

Using EXCEPTION_INIT To handle unnamed internal exceptions, you should use the OTHERS handler or the pragma EXCEPTION_INIT. The pragma is a compiler directive that can be th