我刚刚浪费了生命中过去的两个小时试图创建一个带有自动递增主键的表本教程 http://www.lifeaftercoffee.com/2006/02/17/how-to-create-auto-increment-columns-in-oracle/,教程很棒,我遇到的问题是,如果我有一个时间戳列和同一个表中名为时间戳的表,则创建目标会失败...
为什么在我创建表时 Oracle 不将此标记为问题?
这是我输入的命令序列:
-
创建表:
CREATE TABLE myTable
(id NUMBER PRIMARY KEY,
field1 TIMESTAMP(6),
timeStamp NUMBER,
);
-
创建序列:
CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1;
-
创建触发器:
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;
/
这是我收到的错误消息:
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
任何不包含带有“时间戳”一词的两行的组合都可以正常工作。我本以为语法足以区分关键字和列名。
正如我所说,我不明白为什么表创建得很好,但当我尝试创建触发器时,oracle 崩溃了......
澄清
我知道问题是有一个名为时间戳的列,它可能是也可能不是关键字。我的问题是为什么当我尝试创建触发器时它会崩溃,而不是当我创建表时,我至少会收到警告。
也就是说,使用 Oracle 几个小时后,它的错误报告似乎不那么冗长,也许只是因为我使用的是 Express 版本。
如果这是 Oracle 中的一个错误,没有支持合同的人将如何报告它?我只是在玩快速版本,因为我必须将一些代码从 MySQL 迁移到 Oracle。
Metalink 上有关于此 (227615.1) 摘录的注释如下:
# 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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)