1

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

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: invalid identifier”。我检查了“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

然后我对错误感到困惑。任何人都可以帮助我吗?

提前致谢。

4

1 回答 1

1

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

...可能在创建表期间,列在引号中输入了大写,如下所示:

"DAYTIME"

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

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

其他选项是这样调用此列:

= r_scv.DAYTIME
于 2014-07-23T11:43:58.213 回答