无法调用oracle存储过程和函数
可能这个问题太简单了,但我确实需要帮助。
我正在 Oracle 10g 中创建一个存储过程,但无法调用它。我正在使用 SQL Developer 来管理数据库。
CREATE OR REPLACE
FUNCTION check_login
(username IN VARCHAR2, pwd IN VARCHAR2)
RETURN VARCHAR2
IS
isUserValid INTEGER;
BEGIN
SELECT Count(*) INTO isUserValid
FROM users
WHERE Username = username AND PASS_WORD = pwd;
return isUserValid;
END;
我也尝试过:
CREATE OR REPLACE
PROCEDURE check_login
(username IN VARCHAR2, pwd IN VARCHAR2, RESULT OUT INTEGER)
IS
isUserValid INTEGER;
BEGIN
SELECT Count(*) INTO isUserValid
FROM users
WHERE Username = username AND PASS_WORD = pwd;
RESULT := isUserValid;
END;
解析两者都不会给出任何错误消息。我使用以下语法来调用它们:
BEGIN
check_login('admin', 'admin');
END;
并且
EXECUTE check_login('admin', 'admin');
我收到此错误消息......
PLS-00221:“CHECK_LOGIN”不是过程或未定义
PL/SQL:语句被忽略
如果直接运行,两者中的 SELECT 语句都可以正常工作。
我做错了什么吗?
Might be too simple question to ask, but I do need help.
I am creating a stored procedure in Oracle 10g, but I cannot call it. I am using SQL Developer to manage the database.
CREATE OR REPLACE
FUNCTION check_login
(username IN VARCHAR2, pwd IN VARCHAR2)
RETURN VARCHAR2
IS
isUserValid INTEGER;
BEGIN
SELECT Count(*) INTO isUserValid
FROM users
WHERE Username = username AND PASS_WORD = pwd;
return isUserValid;
END;
I have tried this also:
CREATE OR REPLACE
PROCEDURE check_login
(username IN VARCHAR2, pwd IN VARCHAR2, RESULT OUT INTEGER)
IS
isUserValid INTEGER;
BEGIN
SELECT Count(*) INTO isUserValid
FROM users
WHERE Username = username AND PASS_WORD = pwd;
RESULT := isUserValid;
END;
Parsing both does not give any error message. I used following syntax to call them:
BEGIN
check_login('admin', 'admin');
END;
AND
EXECUTE check_login('admin', 'admin');
I get this error message....
PLS-00221: 'CHECK_LOGIN' is not a procedure or is undefined
PL/SQL: Statement ignored
The SELECT statement inside both works fine if run directly.
Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想执行一个函数,你必须将返回值收集到一个变量中。
因此,您需要定义一个变量并执行函数以返回到该变量,如下所示
,并使用 run Script 选项而不是 Run Statement 选项运行它。
或者如果你从 plsql 来做
If you want to execute a function you have to collect the return value into a variable.
So you need to define a variable and execute function to return into the variable as below
and run it using the run Script option not the Run Statement option.
Or if you do it from plsql
我发现调用函数的最简单方法就是从对偶中选择函数,例如 -
请注意错误消息“No procedure”:)。
I find the easiest way to call a function is just selecting the function from dual eg-
Note the error message said "No procedure' :).