2015-03-19 520 views
1

我想弄清楚爲什麼這會拋出一個錯誤。SQL錯誤:ORA-02315:默認構造函數的參數數量不正確

這是我的對象類型

CREATE type address_typ as object (
    street varchar2(60), 
    city varchar2(19), 
    pCode varchar2(9) 
    ) 
    Final; 

/

CREATE type person_typ as object 
(
pNInum  varchar2(9), 
pName name_typ, 
pAddress address_typ, 
pPhone Phone_array 
) 
Not Final; 

/

CREATE type employee_typ under person_typ 
(
emp_ID varchar2(11), 
joinDate date, 
position varchar2(14), 
salary number,  
branch_r ref branch_typ 
) 
Final; 

/

這是我的表插入查詢。

insert into person_table values(employee_typ('NI001',Name_type('Mrs  ','Alison ','Smith '),address_typ('Dart','Edinburgh', 'EH105TT'),Phone_array('01312125555','07705623443','07907812345'),,to_date('01/02/2016','dd-mm-yyyy'),'Head',50000,(select ref(b) from Branch_table b where b.bid='901'))); 

insert into person_table values(employee_typ('NI010',Name_type('Mr','John','William'),address_typ('New','Edinburgh', 'EH24AB'),Phone_array('01312031990','07902314551','077'),,to_date('04/03/2007','dd-mm-yyyy'),'Manager',40000,(select ref(b) from Branch_table b where b.bid='901'))); 

insert into person_table values(employee_typ('NI120',Name_type('Mr','Mark','Slack'),address_typ('Old','Edinburgh', 'EH94BB'),Phone_array('01312102211','',''),,to_date('01/02/2009','dd-mm-yyyy'),'Accountant',30000,(select ref(b) from Branch_table b where b.bid='901'))); 

insert into person_table values(employee_typ('NI810',Name_type('Mr','Jack','Smith '),address_typ('Adam','Edinburgh', 'EH16EA'),Phone_array('01311112223','0781209890',''),,to_date('05/02/2008','dd-mm-yyyy'),'Project Leader ',35000,(select ref(b) from Branch_table b where b.bid='908'))); 

insert into person_table values(employee_typ('NI234',Name_type('Mr ','Muneeb ','Khan'),address_typ('5432 Castlehill',' Edinburgh', ' EH1 2ND'),Phone_array('01312224535','0745679945','07468452746'),,to_date('20/09/1982','dd-mm-yyyy'),'Project Leader ',35000,(select ref(b) from Branch_table b where b.bid='901'))); 

insert into person_table values(employee_typ('NI256',Name_type('Mrs ','Stephanie ','Fagan '),address_typ('276 Cockburn Street',' Edinburgh', ' EH1 1BP'),Phone_array('01334545454','0776988453','07775744847'),,to_date('14/06/1984','dd-mm-yyyy'),'Cashier ',15000,(select ref(b) from Branch_table b where b.bid='901'))); 

insert into person_table values(employee_typ('NI453',Name_type('Mr','Steven ','Ojay'),address_typ('40 Hutchesontown Court','Glasgow ', ' G5 0SX'),Phone_array('01414567865','0777457457','07564634645'),,to_date('19/07/1985','dd-mm-yyyy'),'Manager',40000,(select ref(b) from Branch_table b where b.bid='902'))); 

insert into person_table values(employee_typ('NI343',Name_type('Miss','Linsday ','Reid '),address_typ('40 Carlton Place','Glasgow ', ' G5 9TW'),Phone_array('01418693048','0756748454','07474757479'),,to_date('19/01/1988','dd-mm-yyyy'),'Project Leader ',35000,(select ref(b) from Branch_table b where b.bid='902'))); 

insert into person_table values(employee_typ('NI896',Name_type('Mr','Stuart ','Reid '),address_typ('451 Lawmoor Street','Glasgow ', ' G54 3EJ'),Phone_array('01418363484','0777373464','07575757779'),,to_date('17/08/1988','dd-mm-yyyy'),'Accountant ',30000,(select ref(b) from Branch_table b where b.bid='902'))); 

insert into person_table values(employee_typ('NI645',Name_type('Miss ','Eveyln ','Ford '),address_typ('197 Cumberland Street','Glasgow ', ' G5 0SW'),Phone_array('01418569235','0773638293','07565656389'),,to_date('07/10/1988','dd-mm-yyyy'),'Cashier ',15000,(select ref(b) from Branch_table b where b.bid='902'))); 

insert into person_table values(employee_typ('NI543',Name_type('Mrs ','Rebbeca ','Duke '),address_typ('33 Queen Elizabeth Gardens','Glasgow ', ' G5 0UH'),Phone_array('01410593032','0736373748','07564749699'),,to_date('06/11/1989','dd-mm-yyyy'),'Manager ',40000,(select ref(b) from Branch_table b where b.bid='903'))); 

insert into person_table values(employee_typ('NI359',Name_type('Miss','Lauren ','Steve'),address_typ('Elmfoot Grove','Glasgow ', ' G5 0HF'),Phone_array('01419582039','0736484848','07464747468'),,to_date('23/05/1991','dd-mm-yyyy'),'Accountant ',30000,(select ref(b) from Branch_table b where b.bid='903'))); 

insert into person_table values(employee_typ('NI880',Name_type('Mr','Laurance ','Builder '),address_typ('232 Paisley Road','Glasgow ', ' G5 8NG'),Phone_array('01415034893','0777363737','07773856960'),,to_date('08/02/1994','dd-mm-yyyy'),'Project Leader ',35000,(select ref(b) from Branch_table b where b.bid='903'))); 

insert into person_table values(employee_typ('NI063',Name_type('Mr','Micheal','Jackson'),address_typ('31C Errol Gardens','Glasgow ', ' G5 0RA'),Phone_array('01415834349','0736383738','07773457374'),,to_date('11/07/1996','dd-mm-yyyy'),'Cashier ',15000,(select ref(b) from Branch_table b where b.bid='903'))); 

insert into person_table values(employee_typ('NI850',Name_type('Mrs ','Rebecca ','Tony'),address_typ('37 Carnoustie Street','Glasgow ', ' G5 8PN'),Phone_array('0141i8349349','0793834949','07583838835'),,to_date('26/12/1996','dd-mm-yyyy'),'Head ',50000,(select ref(b) from Branch_table b where b.bid='904'))); 

回答

0

問題是沒有。每種類型的參數,當你引用或插入給予相同的東西。

你定義address_typ - >person_typperson_typ - (?,你在你的問題定義)>employee_typ和使用branch_typ

CREATE type employee_typ under person_typ 
(
emp_ID varchar2(11), 
joinDate date, 
position varchar2(14), 
salary number,  
branch_r ref branch_typ /*where you define*/ 
) 
Final; 

檢查鏈接。

http://oraclequirks.blogspot.in/2008/06/ora-02315-incorrect-number-of-arguments.html

https://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:10271519764319

+0

'CREATE類型branch_typ作爲對象 ( 出價數, bAddress Address_typ, bPhone Phone_array ) 最終; /' – 2015-03-19 06:05:44

+0

我有這個以及對不起,我沒有把它添加到問題 – 2015-03-19 06:06:52

+0

沒有問題,你檢查鏈接,它是否幫助你。理想的是參數和序號。定義中的參數會導致錯誤。你可以再次檢查100%的注意力,你沒有犯任何錯誤。 – Ajay2707 2015-03-19 06:12:37