PL/SQL 中的函数错误
我尝试创建以下函数:
CREATE OR REPLACE
function CATEGORYTEST(n in number) return VARCHAR(200)
IS
catname VARCHAR(200);
BEGIN
SELECT NAME AS PARENTCAT INTO CATNAME FROM CATEGORY_LANGUAGE WHERE CATEGORY_ID = (
SELECT PARENT_ID
FROM CATEGORY
WHERE ID = N
AND CAT_TYPE_ID = 7
AND IS_ACTIVE = 1
AND IS_DELETED = 0
)
AND IS_ACTIVE = 1
AND IS_DELETED = 0;
RETURN CATNAME;
end;
我收到以下错误:
Error(2,51): PLS-00103: Encountered the symbol "(" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate
我也尝试过 varchar2 但收到相同的错误。
I tried to create following function:
CREATE OR REPLACE
function CATEGORYTEST(n in number) return VARCHAR(200)
IS
catname VARCHAR(200);
BEGIN
SELECT NAME AS PARENTCAT INTO CATNAME FROM CATEGORY_LANGUAGE WHERE CATEGORY_ID = (
SELECT PARENT_ID
FROM CATEGORY
WHERE ID = N
AND CAT_TYPE_ID = 7
AND IS_ACTIVE = 1
AND IS_DELETED = 0
)
AND IS_ACTIVE = 1
AND IS_DELETED = 0;
RETURN CATNAME;
end;
I am getting following error:
Error(2,51): PLS-00103: Encountered the symbol "(" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate
I had tried varchar2 also but getting same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
您需要将字符串文字用单引号括起来,将 VARCHAR 更改为 VARCHAR2 以及其他一些小的更改。
顺便说一句,您的 catname 变量最好声明为:
您可能还想查看也被灵活声明的函数的返回类型,例如:
希望它有帮助......
Try this:
You needed single quotes around your string literals, VARCHAR changed to VARCHAR2 and some other small changes.
BTW, your catname variable would be better declared as:
You might also want to look into the return type of the function also being flexibly declared e.g.:
Hope it helps...
使用此标头:(
返回类型没有长度规范)
Use this header:
(no length specification for the return type)