列存在但仍然收到此错误ORA-00904:无效的标识符

时间:2014-07-23 09:28:17

标签: oracle11g ora-00904

任何人都可以帮我解决这个问题

declare 

    lv2_sql VARCHAR2(32767);

    cursor c_scv is
    select financial_code, object_id, daytime from stream_category_version;

begin

for r_scv in c_scv LOOP

  IF r_scv.financial_code = 'PURCHASE' THEN

   lv2_sql := 'UPDATE stream_category_version ' || CHR(10) || 
   'set REVN_PURCHASES_IND = ''Y'', last_updated_by = nvl(last_updated_by, created_by) '  || CHR(10) || 
   'WHERE object_id = r_scv.object_id AND daytime = r_scv.daytime';
   ecdp_dynsql.execute_statement(lv2_sql);   

  ELSIF r_scv.financial_code = 'SALE' THEN

   lv2_sql := 'UPDATE stream_category_version ' || CHR(10) || 
   'set REVN_SALES_IND = ''Y'', last_updated_by = nvl(last_updated_by, created_by) '  || CHR(10) || 
   'WHERE object_id = r_scv.object_id AND daytime = r_scv.daytime';
   ecdp_dynsql.execute_statement(lv2_sql);  


  END IF;

END LOOP; 

end;

我有如上所示的代码,但我收到错误'ORA-00904:R_SCV.DAYTIME:无效标识符'。我检查了'stream_category_version'的表定义,发现DAYTIME列如下所示

SQL> desc stream_category_version
Name               Type           Nullable Default Comments 
------------------ -------------- -------- ------- -------- 
OBJECT_ID          VARCHAR2(32)                             
DAYTIME            DATE                                     
END_DATE           DATE           Y                         
NAME               VARCHAR2(240)  Y                          
FINANCIAL_CODE     VARCHAR2(32)   Y                         
SORT_ORDER         NUMBER         Y                         
COMMENTS           VARCHAR2(2000) Y

然后我对错误感到困惑。有人可以帮帮我吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

简而言之 - Oracle区分大小写...

...可能在表创建列期间使用引号键入大写:

"DAYTIME"

在你的sql中我看到这个小写的列

因此您应该验证您的列名称,并最好将其更改为不带引号的版本。

其他选项是调用此列:

= r_scv.DAYTIME