ORA-00932:插入时出现不一致的数据类型错误

时间:2018-04-11 18:29:25

标签: sql database oracle

我收到此错误:

  

ORA-00932:数据类型不一致:得到了预期的REF ADDRESS_TYPE   ADDRESS_TYPE

这是我的CREATE脚本:

CREATE OR REPLACE TYPE address_type AS OBJECT
(
    house_name VARCHAR2(20),
    street     VARCHAR2(20),
    city       VARCHAR2(20),
    postcode   VARCHAR2(9)
)
/

CREATE TABLE addresses OF address_type;

CREATE TABLE customers
(
    customer_id NUMBER(6),
    title       VARCHAR2(5),
    firstname   VARCHAR2(20),
    surname     VARCHAR2(20),
    telephone   VARCHAR2(12), --VARCHAR2 used as customer may use +44
    address     REF address_type SCOPE IS addresses
);

这是我的Insert脚本:

INSERT INTO customers (customer_id, title, firstname, surname, telephone, address)
VALUES (1, 'mr', 'ross', 'xd', '01234881632', 
        address_type('exdee', 'may road', 'lurvey', 'rs34 8dt'));

我已尝试将REF address_type放入插入表中,但这不起作用,它只是要求输入逗号。我也尝试从create table中删除REF。我不确定我在这里做错了什么,会感激一些帮助。

1 个答案:

答案 0 :(得分:0)

您不需要REFSCOPE IS address。只需将您的行更改为:

address     address_type

SQLFiddle