将数据插入Oracle数据库

时间:2013-05-10 07:54:00

标签: database oracle object reference insert

我可以帮助您将一些数据插入表格中。

我创建了一个Peripheral_objtyp对象,然后从这个对象创建了一个表:

create type Peripheral_objtyp as Object (
PeriphNo NUMBER,
Comp_ref REF Computer_objtyp,
PeriphName varchar2(20),
PeriphType varchar2(20)
)
/

create table Peripheral_objtab of Peripheral_objtyp (PeriphNo Primary Key) Object ID Primary Key
/

这是Computer_objtyp:

create type Computer_objtyp as object (
CompNo          Number,
CompName    Varchar2(20),
CompOS      Varchar2(20),
CompProcessor   Varchar2(20),
CompRAM     Varchar2(20),
CurrentUser_obj     CurrentUser_objtyp,
HardDriveList_var   HardDriveList_Vartyp )
/

我想在Peripheral_objtab中插入一些数据。这是我尝试过的代码:

INSERT INTO Peripheral_objtab
SELECT 1, REF(C), 'Test', 'Test'
FROM Computer_objtab C
Where C.CompNo = 1;

我收到此错误:

SQL Error: ORA-22979: cannot INSERT object view REF or user-defined REF
22979. 00000 -  "cannot INSERT object view REF or user-defined REF"
*Cause:    Attempt to insert an object view REF or user-defined REF in a
           REF column created to store system generated REF values"
*Action:   Make sure the REF to be inserted is not from an object view
           or from a user-defined REF column

修改

我也尝试了以下内容:

create table Peripheral_objtab of Peripheral_objtyp (PeriphNo Primary Key) OBJECT IDENTIFIER IS SYSTEM GENERATED
/

但是我得到了同样的错误。

0 个答案:

没有答案