Home » SQL & PL/SQL » SQL & PL/SQL » Accessing a Table contains array in Remote DB (oracle 9i)
|
|
|
|
|
Re: Accessing a Table contains array in Remote DB [message #383822 is a reply to message #383812] |
Fri, 30 January 2009 07:17 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
It works for me:-- Object Creation
CREATE TYPE MTR_BAL_INFO_OBJ AS OBJECT
(BALANCE_ID NUMBER,
BALANCE_CURRENT NUMBER(18,2),
BALANCE_CHANGE NUMBER(18,2),
BALANCE_EXPIRY DATE);
/
-- VArray Creation
CREATE TYPE MTR_BAL_INFO_ARRAY
AS VARRAY(20) OF MTR_BAL_INFO_OBJ;
/
-- Table Creation
CREATE TABLE MTR_HISTORY
(
LOGIN_NAME VARCHAR2(30) NOT NULL,
UNIT_TYPE_ID NUMBER,
BALANCE_INFO MTR_BAL_INFO_ARRAY
);
/
insert into mtr_history values ('Me',2,mtr_bal_info_array(mtr_bal_info_obj(1,1,1,sysdate),mtr_bal_info_obj(2,2,2,sysdate+1)));
insert into mtr_history values ('Me',1,mtr_bal_info_array(mtr_bal_info_obj(3,3,3,sysdate+2),mtr_bal_info_obj(4,4,4,sysdate+3)));
select
LOGIN_NAME,
UNIT_TYPE_ID,
x.BALANCE_ID,
x.BALANCE_CHANGE,
x.BALANCE_EXPIRY,
x.BALANCE_CURRENT from mtr_history@loopback a, table(a.balance_info ) x;
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_E BALANCE_CURRENT
------------------------------ ------------ ---------- -------------- --------- ---------------
Me 2 1 1 30-JAN-09 1
Me 2 2 2 31-JAN-09 2
Me 1 3 3 01-FEB-09 3
Me 1 4 4 02-FEB-09 4
Loopback is simple datbase link that connect back to the schema I'm doing this in.
What do you get when you run it?
What version of Oracle are you running - I'm using 10gr2?
[Updated on: Fri, 30 January 2009 07:18] Report message to a moderator
|
|
|
Re: Accessing a Table contains array in Remote DB [message #383877 is a reply to message #383822] |
Fri, 30 January 2009 21:55 |
vboppa
Messages: 22 Registered: November 2008
|
Junior Member |
|
|
SQL> select
LOGIN_NAME,
UNIT_TYPE_ID,
x.BALANCE_ID,
x.BALANCE_CHANGE,
x.BALANCE_EXPIRY,
x.BALANCE_CURRENT from mtr_history@REPO_CC a,
table(a.balance_info ) x;
x.BALANCE_CURRENT from mtr_history@REPO_CC a,
table(a.balance_info ) x
*
ERROR at line 7:
ORA-21700: object does not exist or is marked for delete
I am getting the above error.
Remote database version is 9i
and My database is 10gR2
|
|
|
|
|
|
|
|
|
Re: Accessing a Table contains array in Remote DB [message #384049 is a reply to message #384042] |
Mon, 02 February 2009 00:16 |
vboppa
Messages: 22 Registered: November 2008
|
Junior Member |
|
|
Dear Sir,
>It's working on same DB from different users.
>For the user where it is "not working" TABLE(a.balance_info ) x does not exist.
The schema is on same DB and conatains select table and execute on object of VARRAY previliges.
My requirement is the same table whicha has VARRAY of type object needs to access from other database. For this simply i have created a Database link and issued same query. It's giving error.
Is there any seperate query to select a table which contains VARRAY of object from Remote Database.
I would appreciate your valuable time to resolve my issue.
Thanks
|
|
|
|
Re: Accessing a Table contains array in Remote DB [message #384062 is a reply to message #384051] |
Mon, 02 February 2009 01:08 |
vboppa
Messages: 22 Registered: November 2008
|
Junior Member |
|
|
I hope the following statements can be useful to simulate the prioblem
Statements executed in X Schema of XYZ DB
SQL> CREATE TYPE MTR_BAL_INFO_OBJ AS OBJECT
(BALANCE_ID NUMBER,
BALANCE_CURRENT NUMBER(18,2),
BALANCE_CHANGE NUMBER(18,2),
BALANCE_EXPIRY DATE);
Type created.
SQL> CREATE TYPE MTR_BAL_INFO_ARRAY
AS VARRAY(20) OF MTR_BAL_INFO_OBJ;
Type created.
SQL> CREATE TABLE MTR_HISTORY
( LOGIN_NAME VARCHAR2(30),
UNIT_TYPE_ID NUMBER,
BALANCE_INFO MTR_BAL_INFO_ARRAY
);
Table created.
SQL> insert into mtr_history values ('Me',2,mtr_bal_info_array(mtr_bal_info_obj(1,1,1,sysdate),mtr_bal_info_obj(2,2,2,sysdate+1)));
1 row created.
SQL> insert into mtr_history values ('Me',1,mtr_bal_info_array(mtr_bal_info_obj(3,3,3,sysdate+2),mtr_bal_info_obj(4,4,4,sysdate+3)));
1 row created.
SQL> grant select on MTR_HISTORY to Y;
Grant succeeded.
SQL> grant execute on MTR_BAL_INFO_OBJ to Y;
Grant succeeded.
Statements executed in Y Schema of XYZ DB
SQL> create database link test connect to X identified by X using 'XYZ';
Database link created.
SQL> select a.LOGIN_NAME,a.UNIT_TYPE_ID,x.BALANCE_ID,x.BALANCE_CHANGE,x.BALANCE_EXPIRY,
x.BALANCE_CURRENT from mtr_history@test a, table(a.balance_info ) x;
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_E
------------------------------ ------------ ---------- -------------- ---------
BALANCE_CURRENT
---------------
Me 2 1 1 02-FEB-09
1
Me 2 2 2 03-FEB-09
2
Me 1 3 3 04-FEB-09
3
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_E
------------------------------ ------------ ---------- -------------- ---------
BALANCE_CURRENT
---------------
Me 1 4 4 05-FEB-09
4
Statements executed in Y Schema of XYZ DB
SQL> create database link test connect to X identified by X using 'XYZ';
Database link created.
SQL> select a.LOGIN_NAME,a.UNIT_TYPE_ID,x.BALANCE_ID,x.BALANCE_CHANGE,x.BALANCE_EXPIRY,
x.BALANCE_CURRENT from mtr_history@test a, table(a.balance_info ) x;
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_E
------------------------------ ------------ ---------- -------------- ---------
BALANCE_CURRENT
---------------
Me 2 1 1 02-FEB-09
1
Me 2 2 2 03-FEB-09
2
Me 1 3 3 04-FEB-09
3
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_E
------------------------------ ------------ ---------- -------------- ---------
BALANCE_CURRENT
---------------
Me 1 4 4 05-FEB-09
4
Statements executed in A Schema of ABC DB
SQL> create database link test connect to X identified by X using 'XYZ';
Database link created.
-- Without VARRAY of type object
SQL> select a.LOGIN_NAME, a.UNIT_TYPE_ID from mtr_history@test a;
LOGIN_NAME UNIT_TYPE_ID
------------------------------ ------------
Me 2
Me 1
-- With VARRAY of type object
SQL> select a.LOGIN_NAME,a.UNIT_TYPE_ID,x.BALANCE_ID,x.BALANCE_CHANGE,x.BALANCE_EXPIRY,
x.BALANCE_CURRENT from mtr_history@test a, table(a.balance_info ) x;
x.BALANCE_CURRENT from mtr_history@test a, table(a.balance_info ) x
*
ERROR at line 2:
ORA-21700: object does not exist or is marked for delete
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Accessing a Table contains array in Remote DB [message #463174 is a reply to message #463160] |
Wed, 30 June 2010 00:29 |
vboppa
Messages: 22 Registered: November 2008
|
Junior Member |
|
|
Dear Deepika,
The code is in the following.
SOURCE DATABASE
----------------
SQL> SELECT SYS_OP_GUID() FROM DUAL;
SYS_OP_GUID()
--------------------------------
8A3920795594A9E1E040582B24437453
CREATE TYPE MTR_BAL_INFO_OBJ OID '8A3920795594A9E1E040582B24437453' AS OBJECT
(BALANCE_ID NUMBER,
BALANCE_CURRENT NUMBER(18,2),
BALANCE_CHANGE NUMBER(18,2),
BALANCE_EXPIRY DATE);
Type created.
SQL> SELECT SYS_OP_GUID() FROM DUAL;
SYS_OP_GUID()
--------------------------------
8A392079559CA9E1E040582B24437453
CREATE TYPE MTR_BAL_INFO_ARRAY OID '8A392079559CA9E1E040582B24437453'
AS VARRAY(20) OF MTR_BAL_INFO_OBJ;
Type created.
SQL> CREATE TABLE MTR_HISTORY
( LOGIN_NAME VARCHAR2(30),
UNIT_TYPE_ID NUMBER,
BALANCE_INFO MTR_BAL_INFO_ARRAY
);
Table created.
SQL> insert into mtr_history values ('Me',2,mtr_bal_info_array(mtr_bal_info_obj(1,1,1,sysdate),mtr_bal_info_obj(2,2,2,sysdate+1)));
1 row created.
SQL> insert into mtr_history values ('Me',1,mtr_bal_info_array(mtr_bal_info_obj(3,3,3,sysdate+2),mtr_bal_info_obj(4,4,4,sysdate+3)));
1 row created.
SQL> COMMIT;
Commit complete
REMOTE DATABASE
---------------
SQL> CREATE TYPE MTR_BAL_INFO_OBJ OID '8A3920795594A9E1E040582B24437453' AS OBJECT
(BALANCE_ID NUMBER,
BALANCE_CURRENT NUMBER(18,2),
BALANCE_CHANGE NUMBER(18,2),
BALANCE_EXPIRY DATE);
/
Type created
SQL> CREATE TYPE MTR_BAL_INFO_ARRAY OID '8A392079559CA9E1E040582B24437453'
AS VARRAY(20) OF MTR_BAL_INFO_OBJ;
/
Type created
SQL> select a.LOGIN_NAME,a.UNIT_TYPE_ID,x.BALANCE_ID,x.BALANCE_CHANGE,x.BALANCE_EXPIRY,
2 x.BALANCE_CURRENT from [email]mtr_history@test[/email] a, table(a.balance_info ) x;
LOGIN_NAME UNIT_TYPE_ID BALANCE_ID BALANCE_CHANGE BALANCE_EXPIRY BALANCE_CURRENT
------------------------------ ------------ ---------- -------------------- -------------- --------------------
Me 2 1 1.00 6/30/2010 10:4 1.00
Me 2 2 2.00 7/1/2010 10:45 2.00
Me 1 3 3.00 7/2/2010 10:46 3.00
Me 1 4 4.00 7/3/2010 10:46 4.00
SQL>
Regards
Vasudev Boppa
+91-9740311464
[Updated on: Wed, 30 June 2010 00:57] by Moderator Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Dec 06 22:41:09 CST 2024
|