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
Package STANDARD The package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available

Declaring Exceptions The Exceptions can be declared only in the declarative part of the PL/SQL subprogram, block, or package. By introducing its name, you can declare an excep

Consider the schema for FreeChecking Bank, that we designed given below. Translate the given ER schema into SQL CREATE TABLE statements (indicating primary key, unique and foreign

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_divide then d

Example of COALESCE operator Example: Give the total of marks for each exam (simplified solution) SELECT CourseId, COALESCE ((SELECT SUM (Mark) FROM EXAM_MARK AS EM

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

Project Description: I want to write some SQL statements. The things I need are between pages 5-7. The only problem is that i want it till tomorrow. Skills required is SQL

Fetching with a Cursor The FETCH statements retrieve the rows in the result set one at a time. After each and every fetch, the cursor advance to the next row in the result set

Parameter Modes: You do not require to specify a parameter mode for the input bind arguments (those used, for illustration, in the WHERE clause) as the mode defaults to IN. Th

Define basic operators of relational algebra with an example each