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
INSERT Command in SQL Loosely speaking, INSERT takes the rows of a given source table and adds them to the specified target table, retaining all the existing rows in the targ

Problem: (a) Define the following terms: (i) data mining. (ii) OLAP. (b) Differentiate between snowflake schema and star schema. Support your answer with appropriate

MAX and MIN operator in SQL Example: (SELECT MAX (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') (SELECT MIN (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') Example

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

Using the student and faculty tables create a select query that outputs all students for a specific advisor. Generate the execution plan, select out the explain plan . Create an

Develop Data Business Intelligence Project Project Description: We are linking our Microsoft SQL Database to GoodData Business Intelligence. We are seeking somebody who has e

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

This is a Customer Management project. Customer data is presented in a text file. The program will load this text data into its DB columns. The data mapping is user definable. User

V ariables and Constants in PL/SQL The PL/SQL permits you to declare constants and variables, and then use them in SQL and procedural statements anywhere in the expression. Th

I would like to have a custom MS Access database designed and coded that would help me schedule my customer's orders and that would help me track my employees production output and