Accessing attributes in pl sql, PL-SQL Programming

Assignment Help:

Accessing Attributes:

You can refer to an attribute only by its name not by its position in the object type. To access or modify the value of an attribute, you can use the dot notation. In the illustration below, you assign the value of the attribute den to variable denominator. Then, you can assign the value stored in the variable numerator to attribute the num.

DECLARE

r Rational := Rational(NULL, NULL);

numerator INTEGER;

denominator INTEGER;

BEGIN

...

denominator := r.den;

r.num := numerator;

The Attribute names can be chained, that allows you to access the attributes of the nested object type. For illustration, assume that you define the object types Address and Student, as shown below:

CREATE TYPE Address AS OBJECT (

street VARCHAR2(30),

city VARCHAR2(20),

state CHAR(2),

zip_code VARCHAR2(5)

);

CREATE TYPE Student AS OBJECT (

name VARCHAR2(20),

home_address Address,

phone_number VARCHAR2(10),

status VARCAHR2(10),

advisor_name VARCHAR2(20),

...

);'

Note that that zip_code is an attribute of the object type Address and that Address is the datatype of the attribute home_address in object type Student. If s is a Student object, you can access the value of its zip_code attribute as shown below:

s.home_address.zip_code


Related Discussions:- Accessing attributes in pl sql

Selecting objects in pl sql, Selecting Objects: Suppose that you have ...

Selecting Objects: Suppose that you have run the SQL*Plus script below that creates object type Person and object table persons, and that you have settled the table: CREATE

Build a purchases report that matches the general ledger, Great Plains (Mic...

Great Plains (Microsoft Dynamics) Purchases Report Project Description: I want to build a purchases report that matches the General Ledger. presently, when I join the PM20

Declaring records, Declaring Records Whenever you define a RECORD type...

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

Overloading, Overloading The PL/SQL overloads the subprogram names. T...

Overloading The PL/SQL overloads the subprogram names. That is, you can use similar name for few different subprograms as long as their formal parameters differ in the number

%rowtype - cursors, %ROWTYPE: This attribute gives a record type which ...

%ROWTYPE: This attribute gives a record type which represents a row in the database table or a row fetched from a formerly declared cursor. The Fields in the record and corresp

Miller-urey''s experimental procedure, MILLER-UREY' S EXPERIMENTAL PROCEDU...

MILLER-UREY' S EXPERIMENTAL PROCEDURES - They recreated the probable conditions on the primitive earth in the laboratory. An atmosphere containing hydrogen, ammonia, me

PROCEDURE, Create a procedure named DDPROJ_SP that retrieves project inform...

Create a procedure named DDPROJ_SP that retrieves project information for a specific project based on a project ID. The procedure should have two parameters: one to accept a projec

Differentiate between snowflake schema and star schema, Problem: (a) De...

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

Advantages of exceptions, Advantages of Exceptions Using the exception...

Advantages of Exceptions Using the exceptions for the error handling has many benefits. Without an exception handling, every time you issue a command, you should ensure for th

Initializing and referencing collections, Initializing and Referencing Coll...

Initializing and Referencing Collections Until you initialize a collection, a nested table or varray is automatically null (i.e. the collection itself is null, not its elements)

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd