Accessing attributes in pl sql, PL-SQL Programming

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

Posted Date: 10/6/2012 8:14:23 AM | Location : United States







Related Discussions:- Accessing attributes in pl sql, Assignment Help, Ask Question on Accessing attributes in pl sql, Get Answer, Expert's Help, Accessing attributes in pl sql Discussions

Write discussion on Accessing attributes in pl sql
Your posts are moderated
Related Questions
Primary Key - SQL A PRIMARY KEY specification carries an implicit NOT NULL constraint on each column of the specified key. When more than one key constraint is required, the k

Name Resolution   During the compilation, the PL/SQL compiler relates identifiers like the name of a variable with an address or memory location, actual value, or datatype. Th


Keyword &Parameter Description: index_name: This is an undeclared identifier which can be referenced only within the FORALL statement and only as the collection subscript

EXIT The EXIT statement forces a loop to done unconditionally. Whenever an EXIT statement is encountered, the loop is done immediately and controls the passes to the next statem

Advantages of Wrapping   The PL/SQL Wrapper convert the PL/SQL source code into a transitional form of the object code. By hiding the application internals, the Wrapper secure

LIKE Operator You use the LIKE operator to compare the character value to a pattern. The Case is significant. LIKE returns the Boolean value TRUE when the character patterns mat

Data Types in SQL - Character CHARACTER or, synonymously, CHAR, for character strings. When this type is to be the declared type of something (e.g., a column), the permissible

UNION and OR - SQL SQL supports UNION explicitly but differently from the way it supports JOIN explicitly. As we have seen, JOIN is used exclusively within the FROM clause, su

In Packages The Forward declarations also group logically related subprograms in the package. The subprogram specifications go in the package specification, & the subprogram b