473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

oracle object relatedquery

CREATE OR REPLACE TYPE cust_address_t
AS OBJECT (
street_address VARCHAR2(40),
postal_code VARCHAR2(10),
city VARCHAR2(30),
state_province VARCHAR2(2),
country_id VARCHAR(2));
/

CREATE OR REPLACE TYPE address_book_t AS TABLE OF cust_address_t;

CREATE TABLE cust_address (
custno NUMBER(10),
street_address VARCHAR2(40),
postal_code VARCHAR2(10),
city VARCHAR2(30),
state_province VARCHAR2(2),
country_id VARCHAR2(2))

INSERT INTO cust_address
VALUES (1,'123 Main St.','98040','Mercer Island','WA','US');
INSERT INTO cust_address
VALUES (2,'1 Broadway','10202','New York','NY','US');
INSERT INTO cust_address
VALUES (3,'2462 Edgar Crest','V6L 2C4','Vancouver','BC','CN');
COMMIT;

CREATE TABLE cust_short (
custno NUMBER(10),
name VARCHAR2(30)
);


CREATE OR REPLACE TYPE cust_short_type AS OBJECT (
custno NUMBER(10),
name VARCHAR2(30)
v_address_book_t address_book_t);


INSERT INTO cust_short VALUES (1,'Morgan');
INSERT INTO cust_short VALUES (2,'Cline');
INSERT INTO cust_short VALUES (3,'Scott');

***************Here is end of object made************************

Now using following query we retrive data

select cust_short_type(c.custno,c.name,
cast(multiset(select a.street_address,a.postal_code,a.city,a.state_prov ince,a.country_id
from cust_address a where a.custno=c.custno) as address_book_t))
from cust_short c ;

But using anonomous block we have to retrive field which is inside nested table address_book_t

AND this
address_book_t is inside object cust_short_type

Please go through the following block and try to retrive field street_address
which is inside address_book_t...I am getting error using following code.Please help


declare
v_cust_short cust_short_type;
v_address_book_t address_book_t;

begin
select cust_short_type(c.custno,c.name,
cast(multiset(select a.street_address,a.postal_code,a.city,a.state_prov ince,a.country_id
from cust_address a where a.custno=c.custno) as address_book_t)) into

v_cust_short,v_address_book_t
from cust_short c where c.custno=1;
dbms_output.put_line(cust_short_type.name);

FOR I IN v_address_book_t.FIRST..v_address_book_t.LAST LOOP
--dbms_output.put_line(v_address_book_t(I).v_cust_sh ort);
--dbms_output.put_line(v_address_book_t(i).street_ad dress);
END LOOP;
end;
/
Jul 19 '06 #1
0 1404

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: susmita_ganguly | last post by:
Hi I am trying to upgrade from oracle 8i to oracle 9i on the same server ..I don't know much abt migration . Can anyone help me out. Thanks. Susmita
0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
9
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to...
0
by: ʹÃûÑï | last post by:
ORA-03114: not connected to ORACLE && MS's Bug?? DataBase:Oracle 817 using OracleClient,net framework 1.1 I'm using ADO.Net in C# with Oracle 817. and following is my public data access...
13
by: Chris Botha | last post by:
The machine is running XP Pro with all the latest service packs, etc. I must access an Oracle database so I installed the Oracle client stuff. I can query Oracle from a Windows app, no problem....
0
by: petro | last post by:
I am trying to deploy an asp.net application to my web server. My application uses system.data.oledb to connect to an oracle database. On my development machine I have the oracle client 10g...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.