1

我试图在 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 ")" 

这是我的代码:

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;
4

1 回答 1

4

如果要从查询中设置变量,则应使用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;
于 2012-10-17T13:43:30.377 回答