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 に答える