One PLSQL error

本文记录了在Oracle 10G中使用TIMESTAMP作为字段名时遇到的PL/SQL编译错误PLS-00320,并提供了解决方案。当字段名与数据类型名称相同时,会导致编译失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Everything is OK in 11G but get an error when run it in 10G

SQL> conn / as sysdba
Connected.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Solaris: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> @p.sql

Warning: Procedure created with compilation errors.

SQL> show errors
No errors.
SQL> conn scott/tiger
Connected.
SQL> desc snmp_specific_data
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 STARTTIME                                 NOT NULL TIMESTAMP(6)
 ENDTIME                                   NOT NULL TIMESTAMP(6)
 TIMESTAMP                                 NOT NULL TIMESTAMP(6)
 GROUP_ID                                  NOT NULL NUMBER
 APP_ID                                    NOT NULL NUMBER
 ORG_ID                                    NOT NULL VARCHAR2(255)
 CI_UUID                                   NOT NULL VARCHAR2(255)
 TOTAL                                     NOT NULL NUMBER
 SUCCESS                                   NOT NULL NUMBER
 FAILURE                                   NOT NULL NUMBER
 ADDITION1                                          VARCHAR2(4000)
 ADDITION2                                          VARCHAR2(4000)

SQL> desc snmp_specific_data_raw
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 STARTTIME                                 NOT NULL TIMESTAMP(6)
 ENDTIME                                   NOT NULL TIMESTAMP(6)
 TIMESTAMP                                 NOT NULL TIMESTAMP(6)
 GROUP_ID                                  NOT NULL NUMBER
 APP_ID                                    NOT NULL NUMBER
 ORG_ID                                    NOT NULL VARCHAR2(255)
 CI_UUID                                   NOT NULL VARCHAR2(255)
 TOTAL                                     NOT NULL NUMBER
 SUCCESS                                   NOT NULL NUMBER
 FAILURE                                   NOT NULL NUMBER
 ADDITION1                                          VARCHAR2(4000)
 ADDITION2                                          VARCHAR2(4000)

SQL>@p.sql

SQL> Warning: Procedure created with compilation errors

SQL> show error
No errors.

Check the MOS found:[ID 416303.1]

PL/SQL - Version: 10.2.0.1 to 10.2.0.5 - Release: 10.2 to
Information in this document applies to any platform.

Bug:6331062



PLS-00320 if a column is called "TIMESTAMP"



Component: PLSQL



Fixed Ver(s): 10205 11107 112



Symptom(s):



- Compiling a library unit which refers to a table containing a column whose name is the same as its



datatype fails with PLS-320.



For example:



Have a column called TIMESTAMP of type TIMESTAMP.







create table test_timestamp2 (timestamp timestamp);



insert into test_timestamp2 values (systimestamp);



commit;



create or replace procedure test_timestamp2_proc



IS



BEGIN



insert into test_timestamp2 values (systimestamp);



END;



/



^



Does not compile:



ORA-06552: PL/SQL: Compilation unit analysis terminated



ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed



Available Workaround(s):



Use a different column name from type name.



References:



Note:6331062.8


Bug 6331062 - PLS-320 if a column is called "TIMESTAMP"



But the example provided by docs is not same with mine.

SQL> create table test_timestamp2 (timestamp timestamp);



insert into test_timestamp2 values (systimestamp);





Table created.



SQL> SQL>

1 row created.



commit;

SQL> SQL>

Commit complete.



SQL>

SQL> create or replace procedure test_timestamp2_proc

2

3 IS

4

5 BEGIN

6

7 insert into test_timestamp2 values (systimestamp);

8

9 END;

10

11 /





Warning: Procedure created with compilation errors.



SQL> SQL>

SQL> show error

Errors for PROCEDURE TEST_TIMESTAMP2_PROC:



LINE/COL ERROR

-------- -----------------------------------------------------------------

7/21 PL/SQL: SQL Statement ignored

7/33 PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated

ORA-06553: PLS-320: the declaration of the type of this

expression is incomplete or malformed
But modify the column name then every thing become OK again.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值