Oracle错误:ORA-00900:无效的SQL语句 [英] Oracle ERROR: ORA-00900: invalid SQL statement
问题描述
我正在尝试使用2个函数创建以下数据类型:
I am trying to create the following datatype with 2 functions:
-- Employee
CREATE OR REPLACE TYPE EmployeeType AS OBJECT (
EmployeeNumber NUMBER,
EmployeeName VARCHAR2(150),
EmployeeAddress VARCHAR2(255),
MAP MEMBER FUNCTION getEmployeeNumber RETURN NUMBER,
MEMBER FUNCTION CalculateSalary RETURN FLOAT(2)
)
NOT FINAL;
CREATE OR REPLACE TYPE BODY EmployeeType AS
MAP MEMBER FUNCTION getEmployeeNumber RETURN NUMBER IS
BEGIN
RETURN EmployeeNumber;
END;
-- function that can be overriden by subtypes, make abstract
MEMBER FUNCTION CalculateSalary RETURN FLOAT(2) IS
BEGIN
-- function returns empty, has to be overwritten by fulltimeemployee
RETURN 0.00;
END;
END;
但是我不断收到错误提示
However I keep getting an error stating
ERROR: ORA-00900: invalid SQL statement
Error Code: 900
Query = END
我正在使用RazorSQL执行查询,我似乎无法获取导致此错误的行号,但是通过反复试验,我发现它是我的TYPE BODY
定义中的功能描述之一.
I am using RazorSQL to execute my queries, I cant seem to get the line number causing this error but through trial and error I have found it to be one of the function descriptions in my TYPE BODY
definition.
我尝试在最后一个END;
之后添加/
,但这无助于解决问题.
I have tried adding /
after the last END;
but it does not help solve the issue.
推荐答案
仅用FLOAT
替换FLOAT(2)
:
CREATE OR REPLACE TYPE EmployeeType AS OBJECT (
EmployeeNumber NUMBER,
EmployeeName VARCHAR2(150),
EmployeeAddress VARCHAR2(255),
MAP MEMBER FUNCTION getEmployeeNumber RETURN NUMBER,
MEMBER FUNCTION CalculateSalary RETURN FLOAT
)
NOT FINAL;
/
CREATE OR REPLACE TYPE BODY EmployeeType AS
MAP MEMBER FUNCTION getEmployeeNumber RETURN NUMBER IS
BEGIN
RETURN EmployeeNumber;
END;
-- function that can be overriden by subtypes, make abstract
MEMBER FUNCTION CalculateSalary RETURN FLOAT IS
BEGIN
-- function returns empty, has to be overwritten by fulltimeemployee
RETURN 0.00;
END;
END;
/
CREATE TYPE
的文档没有提及此内容,但是您可以在与CREATE FUNCTION
相关的主题中找到说明:
The documentation for CREATE TYPE
doesn't mention this, but you can find the explanation in the topic related to CREATE FUNCTION
: http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/create_function.htm
RETURN datatype
RETURN数据类型
对于数据类型,请指定函数返回值的数据类型.返回值可以具有任何数据类型 受PL/SQL支持.
......
......
数据类型无法指定长度,精度或小数位数. 数据库得出返回值的长度,精度或小数位数 来自调用该函数的环境.
RETURN datatype
For datatype, specify the data type of the return value of the function. The return value can have any data type supported by PL/SQL.
......
......
The data type cannot specify a length, precision, or scale. The database derives the length, precision, or scale of the return value from the environment from which the function is called.
这篇关于Oracle错误:ORA-00900:无效的SQL语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!