Prev | Current Page 266 | Next

Richard Niemiec

"Oracle Database 10g Performance Tuning Tips & Techniques"

The ADDRESS_TY constructor method contains parameters that
match the datatype??™s attributes, facilitating inserts of new values into the datatype??™s format. In
the following sections, you will see how to create tables that use abstract datatypes, along with
information on the sizing and security issues associated with that implementation.
You can create tables that use abstract datatypes for their column definitions. For example,
you could create an abstract datatype for addresses, as shown here:
create type ADDRESS_TY as object
(Street VARCHAR2(50),
City VARCHAR2(25),
State CHAR(2),
Zip NUMBER);
Once the ADDRESS_TY datatype has been created, you can use it as a datatype when
creating your tables, as shown in the following listing:
Chapter 5: Developing and Implementing Applications 151
create table CUSTOMER
(Name VARCHAR2(25),
Address ADDRESS_TY);
When you create an abstract datatype, Oracle creates a constructor method for use during
inserts. The constructor method has the same name as the datatype, and its parameters are the
attributes of the datatype. When you insert records into the CUSTOMER table, you need to use
the ADDRESS_TY datatype??™s constructor method to insert Address values, as shown here:
insert into CUSTOMER values
('Joe',ADDRESS_TY('My Street', 'Some City', 'ST', 10001));
In this example, the insert command calls the ADDRESS_TY constructor method in order to insert
values into the attributes of the ADDRESS_TY datatype.


Pages:
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
motoryzacja szkoła narciarska wyrejestrowanie samochodu legnica obciążniki Wczasy nad morzem