TOAD无效标识符错误ORA-00904

时间:2017-10-29 18:03:18

标签: sql oracle plsql ddl

我需要帮助解决错误代码ORA-00904。我用这段代码创建了表格

CREATE TABLE OYKUN_EMPLOYEE(
EMPNO INTEGER,
EMP_NAME OYKUN_NAME_TYPE,
EMP_ADDRESS OYKUN_ADDRESS_TYPE,
EMP_BIRTH_DATE DATE,
EMP_DEPARTMENT OYKUN_DEPARTMENT_TYPE,
EMP_MANAGER OYKUN_MANAGER_TYPE,
EMP_SALARY OYKUN_SALARY_TYPE
)
NESTED TABLE EMP_NAME STORE AS OYKUN_EMPNAME
NESTED TABLE EMP_ADDRESS STORE AS OYKUN_EMPADDRESS
NESTED TABLE EMP_DEPARTMENT STORE AS OYKUN_EMPDEPARTMENT
NESTED TABLE EMP_MANAGER STORE AS OYKUN_EMPMANAGER
NESTED TABLE EMP_SALARY STORE AS OYKUN_EMPSALARY;

在我创建表格后,我想插入一些数据,其中包含以下代码

INSERT INTO OYKUN_EMPLOYEE (EMPNO,EMP_NAME,EMP_ADDRESS,EMP_BIRTH_DATE,EMP_DEPARTMENT,EMP_MANAGER,EMP_SALARY) VALUES 
(100,
EMP_NAME (OYKUN_TEMPORAL_VARCHAR('1/1/2007','12/31/2017','Ted Mosby')),
EMP_ADDRESS (OYKUN_TEMPORAL_VARCHAR('1/1/2007','12/31/2017','Manhattan,New York')),
'5/20/1982',
EMP_DEPARTMENT (OYKUN_TEMPORAL_VARCHAR('1/1/2007','12/31/2017','Architect')),
EMP_MANAGER (OYKUN_TEMPORAL_VARCHAR('1/1/2007','12/31/2017','Walter White')),
EMP_SALARY (OYKUN_TEMPORAL_NUMBER('TO_DATE(1/1/2007)','TO_DATE(12/31/2017)',2500))
);

我尝试了所有可能的方法,但我仍然得到“EMP_SALARY”:无效的标识符。

任何人都可以帮我解决这个问题吗?表和列已成功创建。

我还为表创建了类型。

这里,

CREATE TYPE OYKUN_TEMPORAL_VARCHAR AS OBJECT (
VT_LB DATE,
VT_UB DATE,
VALUE VARCHAR2(50)
);

CREATE TYPE OYKUN_TEMPORAL_NUMBER AS OBJECT (
VT_LB DATE,
VT_UB DATE,
VALUE_PART INTEGER
);

CREATE TYPE OYKUN_NAME_TYPE AS TABLE OF OYKUN_TEMPORAL_VARCHAR;
CREATE TYPE OYKUN_ADDRESS_TYPE AS TABLE OF OYKUN_TEMPORAL_VARCHAR;
CREATE TYPE OYKUN_MANAGER_TYPE AS TABLE OF OYKUN_TEMPORAL_VARCHAR;
CREATE TYPE OYKUN_DEPARTMENT_TYPE AS TABLE OF OYKUN_TEMPORAL_VARCHAR;
CREATE TYPE OYKUN_SALARY_TYPE AS TABLE OF OYKUN_TEMPORAL_NUMBER;

1 个答案:

答案 0 :(得分:1)

您应该指明您尝试插入的数据类型,这意味着例如而不是:

`EMP_NAME (OYKUN_TEMPORAL_VARCHAR('1/1/2007','12/31/2017','Ted Mosby')),

你应该:

OYKUN_NAME_TYPE(OYKUN_TEMPORAL_VARCHAR('1/1/2007','31/12/2017','Ted Mosby')),

所以整个插入就像:

INSERT INTO OYKUN_EMPLOYEE (EMPNO,EMP_NAME,EMP_ADDRESS,EMP_BIRTH_DATE,EMP_DEPARTMENT,EMP_MANAGER,EMP_SALARY) VALUES 
(100,
OYKUN_NAME_TYPE(OYKUN_TEMPORAL_VARCHAR('1/1/2007','31/12/2017','Ted Mosby')),
OYKUN_ADDRESS_TYPE (OYKUN_TEMPORAL_VARCHAR('1/1/2007','31/12/2017','Manhattan,New York')),
'20/5/1982',
OYKUN_DEPARTMENT_TYPE (OYKUN_TEMPORAL_VARCHAR('1/1/2007','31/12/2017','Architect')),
OYKUN_MANAGER_TYPE (OYKUN_TEMPORAL_VARCHAR('1/1/2007','31/12/2017','Walter White')),
OYKUN_SALARY_TYPE (OYKUN_TEMPORAL_NUMBER('1/1/2007','31/12/2017',2500))
);

PS。我更改了日期格式,因为我有不同的NLS设置