Home » RDBMS Server » Server Administration » Object REFs
Object REFs [message #372727] Tue, 06 March 2001 07:25
jean-luc buthod
Messages: 3
Registered: March 2001
Junior Member
Hi,

I have a problem with object references in the following example
==================================================================

DROP TABLE employees_tab;
DROP TABLE phones_tab;
DROP TYPE employee_typ;

CREATE OR REPLACE TYPE phone_typ AS OBJECT (
id NUMBER,
nb VARCHAR2(20)
);
/

CREATE OR REPLACE TYPE employee_typ AS OBJECT (
name VARCHAR2(30),
phone REF phone_typ
)
/

CREATE TABLE phones_tab OF phone_typ;
CREATE TABLE employees_tab OF employee_typ;

INSERT INTO phones_tab VALUES (1, '1234');
INSERT INTO phones_tab VALUES (2, '5678');
INSERT INTO employees_tab
SELECT 'major', REF(p) FROM phones_tab p WHERE p.id = 1;
INSERT INTO employees_tab
SELECT 'minor', REF(p) FROM phones_tab p WHERE p.id = 1;
INSERT INTO employees_tab
SELECT 'bush', REF(p) FROM phones_tab p WHERE p.id = 2;

SELECT nb, e.phone, REF(p)
FROM phones_tab p, employees_tab e
WHERE e.phone = ref(p);

=======================================================================================

The result is:
NB
--------------------
PHONE
----------------------------------------------------------------------------------------------------
REF(P)
----------------------------------------------------------------------------------------------------
1234
00002202087ED414113F20E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D
00002802097ED414113F20E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D010001A20000

1234
00002202087ED414113F20E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D
00002802097ED414113F20E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D010001A20000

5678
00002202087ED414113F21E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D
00002802097ED414113F21E1E7E030026461322F2D7ED414113F1EE1E7E030026461322F2D010001A20001

But why is the comparison e.phone = ref(p) OK when the values are different??

Thank you for your help

Jean-Luc
Previous Topic: import gets unknown command error
Next Topic: Re: Command to drop all tables???
Goto Forum:
  


Current Time: Mon Jun 03 01:28:26 CDT 2024