What is the difference between type and a ref to a type in SQL3

Go To StackoverFlow.com

1

What is the difference between the following code?

CREATE TYPE f1_MemberType AS OBJECT (
NINum VARCHAR2(10),
Name VARCHAR2(20),
Address f1_AddressType)
/

and

CREATE TYPE f1_MemberType AS OBJECT (
NINum VARCHAR2(10),
Name VARCHAR2(20),
Address REF f1_AddressType)
/

edit

What's the reason for using REF instead of just giving an element a type?

2012-04-04 21:39
by code511788465541441


1

The difference is that the reference is maintained in memory as a pointer to the actual object, which must then be dereferenced in order to be used as data.

References can be copied between objects more cheaply than copying the data itself (as a pointer would be one simple numeric memory address instead of several fields which could include strings, dates etc). This would allow Addresses to be easily copied between instances of F1_MemberType, at the expence of having to dereference the pointer when you wanted the actual data in the referenced object.

2012-04-04 21:42
by KeithS
Ads