473,466 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inserting into table - object view

35 New Member
in object views
i have a table customer
CUSTID NOT NULL NUMBER
NAME VARCHAR2(25)
STREET VARCHAR2(25)
CITY VARCHAR2(25)
STATE VARCHAR2(25)
PIN NUMBER
then i had created ADT based on cust
Expand|Select|Wrap|Line Numbers
  1. create or replace type ADDRESS_TY as object (street varchar2(25), city varc har2(25), state varchar2(25), pin number);
  2.  
Expand|Select|Wrap|Line Numbers
  1.  create or replace type PERSON_TY as object(name varchar2(25),address ADDRSS_TY);
  2.  
NOW CAN I INSERT INTO CUSTOMER TABLE WITH CONSTUCTOR METHODS OR CAN I INSERT ONLY THORUGH NORMAL WAY OF INSERTION IN RELATIONAL TABLE
Dec 13 '07 #1
9 2141
amitpatel66
2,367 Recognized Expert Top Contributor
in object views
i have a table customer
CUSTID NOT NULL NUMBER
NAME VARCHAR2(25)
STREET VARCHAR2(25)
CITY VARCHAR2(25)
STATE VARCHAR2(25)
PIN NUMBER
then i had created ADT based on cust

create or replace type ADDRESS_TY as object (street varchar2(25), city varc har2(25), state varchar2(25), pin number);
create or replace type PERSON_TY as object(name varchar2(25),address ADDRSS_TY);

NOW CAN I INSERT INTO CUSTOMER TABLE WITH CONSTUCTOR METHODS OR CAN I INSERT ONLY THORUGH NORMAL WAY OF INSERTION IN RELATIONAL TABLE
I dont find you making use of objects in your table customer as per your table structure above. So you can insert using a simple insert statement, you need not use any constructor here.
Dec 13 '07 #2
amitpatel66
2,367 Recognized Expert Top Contributor
Hi Femina,

Please make sure you make use of CODE tags every time when you post and source code in the forum.

Thanks
MODERATOR
Dec 13 '07 #3
femina
35 New Member
SIR
LET ME ADD ONE MORE PONI TO THIS AND MAKE THE QUESTION CLEARER
I HAVE AN OBJECT VIEW ON CUSTOMER TABLE

Expand|Select|Wrap|Line Numbers
  1.  
  2.  create view CUST_OV(custid,Person) as select custid, PERSONN_TY(name, ADDRSS_TY (street, city,state,pin)) from cust; 
  3.  
(CUSTOMER TABLE) NOW PLEASE LET ME KNOW THE ANSWER



I dont find you making use of objects in your table customer as per your table structure above. So you can insert using a simple insert statement, you need not use any constructor here.
Dec 13 '07 #4
femina
35 New Member
HOW TO ADD CODE TAGS
is it like this
sorry since iam a new use please bear with me and clear my doubts

Expand|Select|Wrap|Line Numbers
  1. create object view CUST_OV(custid,Person) as select custid, PERSONN_TY(name, ADDRSS_TY (street, city,state,pin)) from cust;
Dec 13 '07 #5
amitpatel66
2,367 Recognized Expert Top Contributor
HOW TO ADD CODE TAGS
is it like this
sorry since iam a new use please bear with me and clear my doubts

Expand|Select|Wrap|Line Numbers
  1. create object view CUST_OV(custid,Person) as select custid, PERSONN_TY(name, ADDRSS_TY (street, city,state,pin)) from cust;
Please enclose your posted code in [code] tags (See How to Ask a Question).


MODERATOR
Dec 13 '07 #6
debasisdas
8,127 Recognized Expert Expert
What you want to do in the view ?
Dec 13 '07 #7
amitpatel66
2,367 Recognized Expert Top Contributor
Check the below steps would answer your question:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> ed
  3. Wrote file afiedt.buf
  4.  
  5.   1* CREATE OR REPLACE TYPE ADDRESS_TY AS object (street VARCHAR2(25), city varchar2(25), state VARCHAR2(25), pin NUMBER);
  6. SQL> /
  7.  
  8. Type created.
  9.  
  10. SQL> create table cust(custid number,street varchar2(20),city varchar2(10),state varchar2(10),pin number);
  11.  
  12. Table created.
  13.  
  14. SQL> ed
  15. Wrote file afiedt.buf
  16.  
  17.   1* CREATE VIEW CUST_OV(custid,Address) AS SELECT custid, ADDRESS_TY (street, city,state,pin) FROM cust
  18. SQL> /
  19.  
  20. View created.
  21.  
  22. -- Nos performing an insert in cust table and cust_ov view in both the ways, ie using a constructor and then using a simple insert:
  23.  
  24. SQL> insert into cust values(1,'street1','Chennai','TN',600706);
  25.  
  26. 1 row created.
  27.  
  28. -- the below using an object constructor does not work for cust table:
  29.  
  30. SQL> insert into cust values(2, ADDRESS_TY('street2','Chennai','TN','20001'));
  31. insert into cust values(2, ADDRESS_TY('street2','Chennai','TN','20001'))
  32.             *
  33. ERROR at line 1:
  34. ORA-00947: not enough values
  35.  
  36. SQL> insert into cust_ov values(2, ADDRESS_TY('street2','Chennai','TN','20001'));
  37.  
  38. 1 row created.
  39.  
  40. SQL> commit;
  41.  
  42. SQL> select * from cust;
  43.  
  44.    CUSTID STREET               CITY       STATE            PIN
  45. --------- -------------------- ---------- ---------- ---------
  46.         1 street1              Chennai    TN            600706
  47.         2 street2              Chennai    TN             20001
  48.  
  49.  
  50. SQL> select * from cust_ov;
  51.  
  52.    CUSTID
  53. ---------
  54. ADDRESS(STREET, CITY, STATE, PIN)
  55. ----------------------------------------------------------------------------------------------------
  56.         1
  57. ADDRESS_TY('street1', 'Chennai', 'TN', 600706)
  58.  
  59.         2
  60. ADDRESS_TY('street2', 'Chennai', 'TN', 20001)
  61.  
  62. SQL> insert into cust_ov values(3,'street3','chennai','TN','3242343');
  63. insert into cust_ov values(3,'street3','chennai','TN','3242343')
  64.             *
  65. ERROR at line 1:
  66. ORA-00913: too many values
  67.  
  68.  
I hope this helps!!
Dec 13 '07 #8
femina
35 New Member
Thanks A Lot For Your Answer Sir
Dec 13 '07 #9
amitpatel66
2,367 Recognized Expert Top Contributor
Thanks A Lot For Your Answer Sir
You are welcome :)

MODERATOR
Dec 13 '07 #10

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

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
3
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when...
4
by: Tom Dauria | last post by:
What I am trying to do is write a resume into a word document from information in an Access database. I have been using bookmarks and inserting table results into the document and so far it's...
1
by: ajk | last post by:
. Hi, All: I know how to insert files into a Word doc using C#. However, the program I've written to do this runs much too slowly. The "myObj".Application.Selection.InsertFile method executes...
2
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from...
1
by: ing42 | last post by:
I have a problem with inserting records into table when an indexed view is based on it. Table has text field (without it there is no problem, but I need it). Here is a sample code: USE test GO...
2
by: csgraham74 | last post by:
Hello, im using MS Access as a front end to link to MYSQL. although this is possibly an Access issue i thought someone would be able to help me. the error message "ODBC--insert on a linked table...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
16
priyan
by: priyan | last post by:
Hi all, I had created a view from a table employee from my database. View is created sucuessfully and when i inserted data into employee table it is also updated in the view but i tried to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.