本文介绍了创建 UDT 函数时出现 PLS-00539 和 PLS-00538 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Oracle 使用类型创建类型层次结构,但在创建其函数时出现错误 PLS-00539 和 PLS-00538.
I am trying to create a type hierarchy with types using Oracle, but I am getting the errors PLS-00539 and PLS-00538 when creating its functions.
我用来创建类型的代码是:
The code I am using to create the types is:
CREATE OR REPLACE TYPE VC_MNumber AS Object (
idno NUMBER,
MEMBER FUNCTION dimension RETURN NUMBER ,
MEMBER FUNCTION typeName RETURN VARCHAR2) NOT INSTANTIABLE NOT FINAL;
/
DROP TYPE VC_MINTEGER;
CREATE OR REPLACE TYPE VC_MInteger UNDER VC_MNumber (
OVERRIDING MEMBER FUNCTION dimension RETURN NUMBER ,
OVERRIDING MEMBER FUNCTION typeName RETURN VARCHAR2);
/
CREATE OR REPLACE TYPE VC_MReal UNDER VC_MNumber(
YDCCoeff NUMBER,
CbDCCoeff NUMBER,
CrDCCoeff NUMBER,
OVERRIDING MEMBER FUNCTION typeDimension RETURN NUMBER,
OVERRIDING MEMBER FUNCTION typeName RETURN VARCHAR2) FINAL;
/
到目前为止一切正常,但是当我尝试创建函数时:
Everything okay up to this point, but when I try to create the functions:
CREATE OR REPLACE TYPE BODY VC_MReal AS
OVERRIDING MEMBER FUNCTION typeDimension RETURN NUMBER IS
var_dimension number := 10;
BEGIN
RETURN var_dimension;
END;
MEMBER FUNCTION typeName RETURN VARCHAR2 IS
var_typeName VARCHAR2(400) := 'VC_MREAL';
BEGIN
RETURN var_typeName;
END;
END;
/
我收到错误 PLS-00539 和 PLS-00538.我不知道我做错了什么.我很感激这件事.错在哪里?
I get the errors PLS-00539 and PLS-00538. I don't know what I am doing wrong. I'd appreciate a hand on this. Where is the mistake?
推荐答案
您在声明时犯的错误很少见内联解释:
There are few mistakes you made while declaration see explaination inline:
CREATE OR REPLACE TYPE VC_MNumber AS OBJECT
(
idno NUMBER,
MEMBER FUNCTION dimension
RETURN NUMBER,
MEMBER FUNCTION typeName
RETURN VARCHAR2
)
NOT INSTANTIABLE NOT FINAL;
/
--DROP TYPE VC_MINTEGER;
CREATE OR REPLACE TYPE VC_MInteger
UNDER VC_MNumber
(
OVERRIDING MEMBER FUNCTION dimension
RETURN NUMBER,
OVERRIDING MEMBER FUNCTION typeName
RETURN VARCHAR2
);
/
CREATE OR REPLACE TYPE VC_MReal
UNDER VC_MNumber
(
YDCCoeff NUMBER,
CbDCCoeff NUMBER,
CrDCCoeff NUMBER,
OVERRIDING MEMBER FUNCTION Dimension --<--Overriding function should have same name
RETURN NUMBER,
OVERRIDING MEMBER FUNCTION typeName
RETURN VARCHAR2
)
FINAL;
/
CREATE OR REPLACE TYPE BODY VC_MReal
AS
OVERRIDING MEMBER FUNCTION Dimension
RETURN NUMBER
IS
var_dimension NUMBER := 10;
BEGIN
RETURN var_dimension;
END;
OVERRIDING MEMBER FUNCTION typeName --<-- You declared in Object type as `overriding` function and using it as `Member function` alone.
RETURN VARCHAR2
IS
var_typeName VARCHAR2 (400) := 'VC_MREAL';
BEGIN
RETURN var_typeName;
END;
END;
/
这篇关于创建 UDT 函数时出现 PLS-00539 和 PLS-00538 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!