Oma*_*eji 5 sql oracle ora-06553
我刚刚浪费了我生命中的最后两个小时试图在本教程中创建一个带有自动递增主键的表,该教程非常棒,我遇到的问题是如果我有一个列,Create Target会失败这是一个时间戳和一个在同一个表中称为时间戳的表...
为什么oracle在创建表时不会将此标记为问题?
这是我输入的命令序列:
创建表:
CREATE TABLE myTable
(id NUMBER PRIMARY KEY,
field1 TIMESTAMP(6),
timeStamp NUMBER,
);
Run Code Online (Sandbox Code Playgroud)创建序列:
CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1;
Run Code Online (Sandbox Code Playgroud)创建触发器:
CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON myTable
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
END;
/
Run Code Online (Sandbox Code Playgroud)这是我收到的错误消息:
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
Run Code Online (Sandbox Code Playgroud)
没有两行中带有"timestamp"一词的任何组合都可以正常工作.我原以为语法足以区分关键字和列名.
正如我所说,我不明白为什么表创建正常,但当我尝试创建触发器时,oracle会崩溃...
澄清
我知道问题是有一个名为timestamp的列可能是也可能不是关键字.我的问题是为什么当我试图创建一个触发器而不是在我创建表时它被禁止,我至少会预料到一个警告.
这说使用Oracle几个小时,它的错误报告似乎不那么冗长,也许只是因为我使用的是快递版本.
如果这是Oracle中的一个错误,那么没有支持合同的人会如何报告?我只是在使用快速版本,因为我必须将一些代码从MySQL迁移到Oracle.
关于这个(227615.1)提取物的metalink上有一个注释如下:
# symptom: Creating Trigger fails
# symptom: Compiling a procedure fails
# symptom: ORA-06552: PL/SQL: %s
# symptom: ORA-06553: PLS-%s: %s
# symptom: PLS-320: the declaration of the type of this expression is incomplete or malformed
# cause: One of the tables being references was created with a column name that is one of the datatypes (reserved key word). Even though the field is not referenced in the PL/SQL SQL statements, this error will still be produced.
fix:
Workaround:
1. Rename the column to a non-reserved word.
2. Create a view and alias the column to a different name.
Run Code Online (Sandbox Code Playgroud)