我尝试在 Oracle 11G 中创建存储过程,但出现以下异常:
Error(7,18): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternat
Error(9,65): PLS-00103: Encountered the symbol ")"
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
create or replace
procedure PM_LOG_IN_SP(user_name_ in nvarchar2, password_ in nvarchar2, res out int)
is
begin
IF user_name_ is not null and password_ is not null then
res := (SELECT count(*)
FROM HR.SYSTEM_USERS_TBL S
WHERE S.USER_NAME = user_name_ AND S.PSWD = password_;)
ELSE
RES :=0;
END IF;
end PM_LOG_IN_SP;
Run Code Online (Sandbox Code Playgroud)
如果你想从查询中设置变量,你应该使用select into子句:
create or replace
procedure PM_LOG_IN_SP(user_name_ in nvarchar2,
password_ in nvarchar2,
res out int)
is
begin
IF user_name_ is not null and password_ is not null then
SELECT count(*)
into res
FROM HR.SYSTEM_USERS_TBL S
WHERE S.USER_NAME = user_name_ AND S.PSWD = password_;
ELSE
RES :=0;
END IF;
end PM_LOG_IN_SP;
Run Code Online (Sandbox Code Playgroud)