[英]Oracle ERROR: ORA-00900: invalid SQL statement
I am trying to create the following datatype with 2 functions: 我正在尝试使用2个函数创建以下数据类型:
-- 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
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. 我正在使用RazorSQL执行查询,我似乎无法获取导致此错误的行号,但是通过反复试验,我发现它是TYPE BODY
定义中的功能描述之一。
I have tried adding /
after the last END;
我尝试在最后一个END;
之后添加/
END;
but it does not help solve the issue. 但这无助于解决问题。
Replace FLOAT(2)
with just FLOAT
: 更换FLOAT(2)
只有FLOAT
:
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;
/
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 CREATE TYPE
的文档没有提及此内容,但是您可以在与CREATE FUNCTION
相关的主题中找到说明: http : //docs.oracle.com/cd/B28359_01/appdev.111/b28370/create_function.htm RETURN数据类型
RETURN datatype RETURN数据类型
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. 返回值可以具有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. 数据库从调用函数的环境中得出返回值的长度,精度或小数位数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.