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

Controlling autonomous transactions, Controlling Autonomous Transactions ...

Controlling Autonomous Transactions The first SQL statement in an autonomous routine starts a transaction. Whenever one transaction ends, the next SQL statement starts the oth

Sql cursor - syntax, SQL Cursor   The Oracle implicitly opens a cursor...

SQL Cursor   The Oracle implicitly opens a cursor to process each SQL statement not related with an explicit cursor. The PL/SQL refers to the most current implicit cursor as t

Application to export excel data to mssql server table, Application to Expo...

Application to Export Excel Data to MSSQL Server table I am having a table available in excel format and features the subsequent: - Some text is in Arabic (e.g. UTF-8 encodin

Methods in pl/sql, Methods: In normal, a method is a subprogram declar...

Methods: In normal, a method is a subprogram declared in an object type specification using the keyword MEMBER or STATIC. The method cannot have similar name as the object typ

Using %rowtype-declarations in sql, Using %ROWTYPE The %ROWTYPE attribut...

Using %ROWTYPE The %ROWTYPE attribute gives a record type which represents a row in a table (or view). The record can store the whole row of data selected from the table or fetc

Understanding nested tables, Understanding Nested Tables Within the data...

Understanding Nested Tables Within the database, the nested tables can be considered as one-column database tables. The Oracle stores the rows of a nested table in no specific o

Opening a cursor, Opening a Cursor Opening the cursor executes the que...

Opening a Cursor Opening the cursor executes the query & identifies the result set that consists of all rows that meet the query search criteria. For the cursors declared usin

Named notation, Named Notation The second procedure call uses the name...

Named Notation The second procedure call uses the named notation. An arrow (=>) serve as the relationship operator that associates the formal parameter to the left of the arro

Operator precedence-pl/sql expressions , Operator Precedence The operati...

Operator Precedence The operations within an expression are completed in a particular order depending on their precedence (priority). The table shows the default order of the op

Parameter & keyword description-execute immediate statement, Parameter and ...

Parameter and Keyword Description: dynamic_string: This is a string variable, literal, or expression which represents a SQL statement or the PL/SQL block. define_vari

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