将数据更新/插入表中的表 - ORA-00904

时间:2015-02-26 14:33:20

标签: sql oracle sql-update sql-insert sqlcode

我正在尝试将数据插入/更新到表中但我得到的是ORA-00904 - 无效的标识符。

使用这样的表定义:

    CREATE TABLE "TST"."R0_RL_EST_SHARE" 
   (    "ID" NUMBER(19,0), 
    "BUILDING_SOCIETY_SHARE" CHAR(1 CHAR), 
    "EDITED_BY_USER" CHAR(1 CHAR), 
    "OBJECT_CREATED_ON" TIMESTAMP (6), 
    "OBJECT_TYPE" VARCHAR2(2048 CHAR), 
    "OBJECT_UPDATED_ON" TIMESTAMP (6), 
    "OBJECT_VERSION" NUMBER(19,0), 
    "REAL_ESTATE_SHARE_D" NUMBER(19,0), 
    "REAL_ESTATE_SHARE_N" NUMBER(19,0), 
    "MORTGAGE_OBJECT_ID" NUMBER(19,0), 
    "REAL_ESTATE_ID" NUMBER(19,0), 
    "SELLING_SHARE_OF_ID" NUMBER(19,0), 
    "PARTY_ID" NUMBER(19,0)
   )

CREATE TABLE "TST"."PARTY_SHARE" 
   (    "PARTY_ID" NUMBER(19,0), 
    "REAL_ESTATE_SHARE_ID" NUMBER(19,0)
   )

两个表都有数千行。 TST.R0_RL_EST_SHARE中的​​PARTY_ID列为空 - 充满空值。我需要将PARTY_SHARE中的​​PARTY_ID数据插入到R0_RL_EST_SHARE,条件是R0_RL_EST_SHARE中的​​ID与PARTY_SHARE中的​​R0_RL_EST_SHARE_ID相同。

我尝试过很多东西,但它总是以ORA-00904结尾 - 标识符无效。

这是我的插页:

insert into R0_RL_EST_SHARE (PARTY_ID)
select PARTY_ID from PARTY_SHARE
where R0_RL_EST_SHARE.ID = PARTY_SHARE.REAL_ESTATE_SHARE_ID

及其错误代码:

Error starting at line : 6 in command -
insert into R0_RL_EST_SHARE (PARTY_ID)
select PARTY_ID from PARTY_SHARE
where "TST"."R0_RL_EST_SHARE".ID = PARTY_SHARE.REAL_ESTATE_SHARE_ID
Error at Command Line : 8 Column : 7
Error report -
SQL Error: ORA-00904: "TST"."R0_RL_EST_SHARE"."ID": neplatný identifikátor
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

感谢您的帮助......

1 个答案:

答案 0 :(得分:2)

如果我正确理解您的问题,您实际上是在尝试update您的数据,而不是insert

这是一种方式:

update R0_RL_EST_SHARE 
set party_id = (
   select party_id 
   from PARTY_SHARE 
   where R0_RL_EST_SHARE.id = PARTY_SHARE.REAL_ESTATE_SHARE_ID)