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 context As the figure shows, the major transaction shares its context with the nested transactions, but not with the autonomous transactions. Similarly, If one aut

Loop Labels Like the PL/SQL blocks, loops can also be labeled. The label, an undeclared identifier enclosed by double angle brackets, should appear at the beginning of the LOOP

Use Bulk Binds If SQL statements execute inside a loop using the collection elements as bind variables, context switching between the PL/SQL & SQL engines can slow down the ex

Packaging Cursors   You can split a cursor specification from its body for placement in a package. In that way, you can change the cursor body without changing the cursor spec

heap sort program in pl/sql

Tautologies: Above given table allows us to read the truth of the connectives in the next manner. Just expect we are looking at row three. It means this says that, if there P

ROWID and UROWID Internally, every database table has a ROWID pseudo column that stores binary values known as rowids. Each rowid shows the storage address of a row. A physical

Explicit Cursor Attributes The cursor variable or each cursor has four attributes: %FOUND, %ISOPEN, %ROWCOUNT, and %NOTFOUND. When appended to the cursor or cursor variable, th

Records Records are the items of the type RECORD. The Records have exclusively named fields that can store the data values of various types. And hence, a record treat associate

NULL Statement The NULL statement clearly specifies in action; it does nothing other than to pass control to the next statement. It can, though, improve the readability. In a