oracle 错误:ORA-02289 (2: 10):PL/SQL:ORA-02289
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9077897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: ORA-02289 (2: 10): PL/SQL: ORA-02289
提问by DulluActs
I am writing a Trigger for Toad. But I am facing an error like
我正在为 Toad 编写触发器。但我正面临这样的错误
"[Error] ORA-02289 (2: 10): PL/SQL: ORA-02289: sequence does not exist".
CREATE OR REPLACE TRIGGER ACTSINFO.USERMASTER_INSERT
BEFORE INSERT
ON ACTSINFO.USERMASTER
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
BEGIN
SELECT USERMASTER_ID_SEQ.NEXTVAL INTO :NEW.ID FROM dual;
END;
Can anyone help me? I am newcomer to toad.
谁能帮我?我是蟾蜍的新手。
回答by Damian Leszczyński - Vash
The Quest Software is only a tool. In thid case you have a precise error about what went wrong. As the message says, a sequence called USERMASTER_ID_SEQ do not exist in your schema.
Quest 软件只是一个工具。在这种情况下,您对出了什么问题有一个准确的错误。正如消息所说,您的架构中不存在名为 USERMASTER_ID_SEQ 的序列。
The solution might be adding the schema name (owner) before the name of sequence:
解决方案可能是在序列名称之前添加模式名称(所有者):
ACTSINFO.USERMASTER_ID_SEQ
You can find the owner with this query:
您可以通过以下查询找到所有者:
select sequence_owner
from all_sequences
where sequence_name = 'USERMASTER_ID_SEQ';
If that does not help it means that you do not have rights to the sequence or it really does not exist. So either you need to get the sequence's owner to grant SELECT on it to your user or you must create the sequence in the database.
如果这没有帮助,则意味着您没有该序列的权利,或者它确实不存在。因此,要么您需要让序列的所有者将 SELECT 授予您的用户,要么您必须在数据库中创建序列。
To create a sequence you may want use the GUI of Toad. Or just use the PL/SQL statement
要创建序列,您可能需要使用 Toad 的 GUI。或者只是使用 PL/SQL 语句
CREATE SEQUENCE ACTSINFO.USERMASTER_ID_SEQ
INCREMENT BY 1
MAXVALUE 99999999999999999999
MINVALUE 1
CACHE 20 ;