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

Calling constructors in pl sql, Calling Constructors: The Calls to a c...

Calling Constructors: The Calls to a constructor are allowed wherever the function calls are allowed. Similarly to the functions, a constructor is called as a section of an ex

Comparison operators - sql operators, Comparison Operators Usually, yo...

Comparison Operators Usually, you use the comparison operators in the WHERE clause of a data manipulation statement to form the predicates, that compare one expression to anot

Loop labels- iterative control, Loop Labels Like the PL/SQL blocks, loop...

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

Table represents an extension - sql, Table Represents an Extension - SQL ...

Table Represents an Extension - SQL It describes how each tuple in a relation represents a true instantiation of some predicate and each true instantiation is represented by s

Data type conversion, Datatype Conversion At times it is necessary to c...

Datatype Conversion At times it is necessary to convert a value from one datatype to another. For e.g. if you want to inspect a rowid, you should convert it to a character stri

Logical connectives - sql, Logical Connectives - SQL SQL's extended t...

Logical Connectives - SQL SQL's extended truth tables in which the symbol, for unknown, appears along with the usual T and F. Negation (NOT, ¬) Conjunction (

Row operators - sql operators, Row Operators The Row operators return ...

Row Operators The Row operators return or reference the particular rows. ALL retains the duplicate rows in the result of a query or in an aggregate expression. The DISTINCT el

%rowcount - implicit cursor attributes, %ROWCOUNT The %ROWCOUNT yields...

%ROWCOUNT The %ROWCOUNT yields the number of rows affected by the INSERT, UPDATE, or DELETE statement, or returned by a SELECT INTO statement. The %ROWCOUNT yields zero when a

Create a procedure that update the status, Create a procedure named STATUS_...

Create a procedure named STATUS_SHIP_SP that allows a company to employee in the Shipping Department to update the status of an order to add shipping information. The BB_BASKETSTAT

Controlling cursor variables, Controlling Cursor Variables You use 3 s...

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

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