oracle 02303,-----出错信息:ORA-02303: 无法使用类型或表的相关性来删除或取代一个类型...

-----出错信息

CREATE OR REPLACE TYPE Point AS OBJECT (

*

ERROR 位于第 1 行:

ORA-02303: 无法使用类型或表的相关性来删除或取代一个类型

------脚本

REM Point.sql

REM Chapter 12, Oracle8i Advanced PL/SQL Programming

REM by Scott Urman

REM This object type represents a point on a Cartesian grid.

CREATE OR REPLACE TYPE Point AS OBJECT (

-- A point is represented by its location on an X-Y Cartesian

-- grid.

x NUMBER,

y NUMBER,

-- Returns a string '(x, y)'

MEMBER FUNCTION ToString RETURN VARCHAR2,

PRAGMA RESTRICT_REFERENCES(ToString, RNDS, WNDS, RNPS, WNPS),

-- Returns the distance between p and the current Point (SELF).

-- If p is not specified then it defaults to (0, 0).

MEMBER FUNCTION Distance(p IN Point DEFAULT Point(0,0))

RETURN NUMBER,

PRAGMA RESTRICT_REFERENCES(Distance, RNDS, WNDS, RNPS, WNPS),

-- Returns the sum of p and and the current Point.

MEMBER FUNCTION Plus(p IN Point) RETURN Point,

PRAGMA RESTRICT_REFERENCES(Plus, RNDS, WNDS, RNPS, WNPS),

-- Returns the current Point * n.

MEMBER FUNCTION Times(n IN NUMBER) RETURN Point,

PRAGMA RESTRICT_REFERENCES(Times, RNDS, WNDS, RNPS, WNPS)

);

/

show errors

CREATE OR REPLACE TYPE BODY Point AS

-- Returns a string '(x, y)'

MEMBER FUNCTION ToString RETURN VARCHAR2 IS

v_Result VARCHAR2(20);

v_xString VARCHAR2(8) := SUBSTR(TO_CHAR(x), 1, 8);

v_yString VARCHAR2(8) := SUBSTR(TO_CHAR(y), 1, 8);

BEGIN

v_Result := '(' || v_xString || ', ';

v_Result := v_Result || v_yString || ')';

RETURN v_Result;

END ToString;

-- Returns the distance between p and the current Point (SELF).

-- If p is not specified then it defaults to (0, 0).

MEMBER FUNCTION Distance(p IN Point DEFAULT Point(0,0))

RETURN NUMBER IS

BEGIN

RETURN SQRT(POWER(x - p.x, 2) + POWER(y - p.y, 2));

END Distance;

-- Returns the sum of p and and the current Point.

MEMBER FUNCTION Plus(p IN Point) RETURN Point IS

v_Result Point;

BEGIN

v_Result := Point(x + p.x, y + p.y);

RETURN v_Result;

END Plus;

-- Returns the current Point * n.

MEMBER FUNCTION Times(n IN NUMBER) RETURN Point IS

v_Result Point;

BEGIN

v_Result := Point(x * n, y * n);

RETURN v_Result;

END Times;

END;

/

show errors

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值