Oracle错误ORA-06512 [英] Oracle Error ORA-06512

查看:4564
本文介绍了Oracle错误ORA-06512的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是不知道为什么会给我ORA-06512错误

Just can't figure out why it gives me ORA-06512 Error

PROCEDURE PX(pNum INT,pIdM INT,pCv VARCHAR2,pSup FLOAT)
AS
    vSOME_EX EXCEPTION;

BEGIN 
    IF ((pNum < 12) OR (pNum > 14)) THEN     
        RAISE vSOME_EX;
    ELSE  
        EXECUTE IMMEDIATE  'INSERT INTO M'||pNum||'GR (CV, SUP, IDM'||pNum||') VALUES('||pCv||', '||pSup||', '||pIdM||')';
    END IF;
END PX;

进行插入的表的结构基础:

The structure base for the table where the insert is made:

CREATE TABLE "DB"."M12GR" (
    "IDM12GR" NUMBER(10,0) NOT NULL ENABLE, 
    "CV" VARCHAR(5) NOT NULL ENABLE, 
    "SUP" FLOAT(126) NOT NULL ENABLE, 
    "IDM12" NUMBER(10,0) NOT NULL ENABLE, 

    CONSTRAINT "PRIMARY_30" PRIMARY KEY ("IDM12GR"),
    CONSTRAINT "M12SUELORM12" FOREIGN KEY ("IDM12") REFERENCES "DB"."M12" ("IDM12") ENABLE
)

推荐答案

ORA-06512是错误堆栈的一部分.它为我们提供了发生异常的行号,但没有给出异常的原因.通常会在堆栈的其余部分(您尚未发布)中指出这一点.

ORA-06512 is part of the error stack. It gives us the line number where the exception occurred, but not the cause of the exception. That is usually indicated in the rest of the stack (which you have still not posted).

在你说的评论中

仍然,当pNum不在12到14之间时出现错误;当pNum时出现错误 介于12到14之间,就不会失败"

"still, the error comes when pNum is not between 12 and 14; when pNum is between 12 and 14 it does not fail"

好吧,您的代码可以做到这一点:

Well, your code does this:

IF ((pNum < 12) OR (pNum > 14)) THEN     
    RAISE vSOME_EX;

也就是说,当pNum不在12到14之间时,它将引发异常.那么错误堆栈的其余部分是否包括这一行?

That is, it raises an exception when pNum is not between 12 and 14. So does the rest of the error stack include this line?

ORA-06510: PL/SQL: unhandled user-defined exception

如果是这样,您所需要做的就是添加一个异常块来处理该错误.也许:

If so, all you need to do is add an exception block to handle the error. Perhaps:

PROCEDURE PX(pNum INT,pIdM INT,pCv VARCHAR2,pSup FLOAT)
AS
    vSOME_EX EXCEPTION;

BEGIN 
    IF ((pNum < 12) OR (pNum > 14)) THEN     
        RAISE vSOME_EX;
    ELSE  
        EXECUTE IMMEDIATE  'INSERT INTO M'||pNum||'GR (CV, SUP, IDM'||pNum||') VALUES('||pCv||', '||pSup||', '||pIdM||')';
    END IF;
exception
    when vsome_ex then
         raise_application_error(-20000
                                 , 'This is not a valid table:  M'||pNum||'GR');

END PX;

文档涵盖了深入处理PL/SQL异常的信息.

The documentation covers handling PL/SQL exceptions in depth.

这篇关于Oracle错误ORA-06512的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆