简单的PL / SQL过程。获取PL / SQL:忽略SQL语句

时间:2014-08-30 15:39:32

标签: oracle stored-procedures plsql

尝试创建一个非常简单的身份验证过程,以便在Oracle APEX中使用。我的程序在下面

create or replace function pmats_authenticate(uname in varchar2, pass in varchar2)
return boolean
as
begin
   declare
   afound number:=0;
   begin
     select 1 from dual into afound;
     if afound = 1 then
        return true;
     else
        return false;
     end if;
   end;
end pmats_authenticate;

我得到旧的PL / SQL:SQL语句忽略了选择。我把选择归结为我能想到的最简单的事情,从双'中选择1。我很害怕这个问题。

1 个答案:

答案 0 :(得分:3)

INTO子句在FROM子句之前,因此您的SELECT语句应该是

SELECT 1 INTO afound FROM DUAL

作为参考,SELECT的一般结构是

WITH ...common table expressions...
SELECT ...fields...
INTO ...bind variables...
FROM ...tables...
INNER JOIN ...other tables... ON ...conditions...
LEFT|RIGHT|FULL OUTER JOIN ...other tables... ON ...conditions...
WHERE ...conditions...
GROUP BY ...fields...
HAVING ...conditions...

分享并享受。