所以目前我的数据库的内容如下:REF与对象的关系型数据库查询
//branch table
create type branch_Type as object(bID number(6), branch_id ref branch_Type, b_street varchar2(20), b_city varchar2(20), b_p_code varchar2(8), b_bPhone number(14));
create table branch of branch_Type;
INSERT INTO branch VALUES(branch_Type('901', NULL, 'Market', 'Edinburgh', 'EH5 1AB', '01311235560'));
INSERT INTO branch VALUES(branch_Type('908', NULL, 'Bridge', 'Glasgow', 'G18 1QQ', '01413214556'));
insert into branch SELECT branch_Type('901', ref(e), b_street, b_city, b_p_code, b_bPhone) from branch e where e.BID = '901';
insert into branch SELECT branch_Type('908', ref(e), b_street, b_city, b_p_code, b_bPhone) from branch e where e.BID = '908';
//employee table
create type employee_Type as object(e_bid ref branch_Type, empID number(8), e_street varchar2(20), e_city varchar2(20), e_p_code varchar2(8), e_title varchar2(4), e_firstname_surname varchar2(20), emphomephone number(14), emp_mobile_1_2 number(22), supervisorID number(6), e_position varchar2(20), salary number(5), e_ninum varchar2(8), joindate date);
create table employee of employee_Type;
insert into employee select ref(e), '101', 'Dart', 'Edinburgh', 'EH1 05T', 'Mrs', 'Alison Smith', '01312125555', '0770562344307907812345', NULL, 'Head', '50000', 'NI001', '01-FEB-06'
from branch e where e.bid = '901';
insert into employee select ref(e), '105', 'New', 'Edinburgh', 'EH2 4AB', 'Mr', 'John William', 01312031990, 07902314551077, '101', 'Manager', '40000', 'NI010', '04-MAR-07'
from branch e where e.bid = '901';
insert into employee select ref(e), '108', 'Old', 'Edinburgh', 'EH9 4BB', 'Mr', 'Mark Slack', 01312102211, NULL, '105', 'accountant', '30000', 'NI120', '01-Feb-09'
from branch e where e.bid = 901;
insert into employee select ref(e), '804', 'Adam', 'Edinburgh', 'EH1 6EA', 'Mr', 'Jack Smith', 01311112223, 0781209890, '801', 'Leader', '35000', 'NI810', '05-Feb-08'
from branch e where e.bid = 908;
select e_bid from EMPLOYEE where e_bid = '901'; //query I'm using
我想查询员工表中被引用到分支表,但投标的,当我运行工作表脚本输出告诉我,我没有选择行。
'ORA-02315:对于在第一次插入语句默认constructor'参数数目不正确。 – MT0
如果您在第三条插入语句中修复了不匹配的括号,那么您会得到'ORA-00904:“E”。“BID”:无效标识符......请修复您的脚本,使其实际执行。 – MT0
我添加了数据库的新代码。 – Scott