如何克服基本插入上的持久性oracle“无效标识符”错误?

BadCoder

我正在尝试使用子类型创建基本表,并在Oracle Express 11g中向其中插入一些数据。

我的表已成功创建,但是我在插入数据时遇到问题。

我的插入语句的结果总是抛出错误“ SQL错误:ORA-00904:“ BRANCH_PHONE”:无效的标识符“。

尽管表中存在该列,但错误消息中显示的列始终是插入语句末尾的列。我尝试了以下代码:

create type addressType as object(
street varchar2(20),
city varchar2(20),
postCode varchar2(8))
not final
/
create type branchType as object(
branchID int,
branch_address addressType,
branch_phone int(11))
not final
/
create table Branch of branchType(
    constraint branch_pk primary key(branchID));
/
insert into Branch values (
branchID('2364'), 
addressType('12 Rooster','Atlantis','A13 4UG'),
branch_phone('01316521311'));

我真的很感谢任何想法。

老程序员

我进行了一些更改,包括将branch_phone更改为varchar2。电话号码是“数字”,不是数字的数据类型。它是一个字符串。另外,您将branchID作为字符串传递,但是您将其声明为数字,因此也进行了更改。BranchID和branch_phone是原始数据类型,因此不需要构造函数。

create type addressType as object(
street varchar2(20),
city varchar2(20),
postCode varchar2(8))
not final
/
create type branchType as object(
branchID int,
branch_address addressType,
branch_phone varchar2(11))
not final
/
create table Branch of branchType(
    constraint branch_pk primary key(branchID));
/
insert into Branch values (
branchtype(2364,
           addressType('12 Rooster','Atlantis','A13 4UG'),
           '01316521311') )

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章