如果 WHERE 如下所示,则以下 PL/SQL 代码的行为会有所不同:
WHERE USERNAME = 'aaaaaa'
如果看起来像这样,则不同:
WHERE USERNAME = userName
为什么结果不一样 if userName := 'aaaaaa'
?我究竟做错了什么?谢谢!
declare
isFound NUMBER;
userName VARCHAR2(30);
begin
isFound := 0;
userName := 'aaaaaa';
SELECT COUNT(*)
INTO isFound
FROM MyTable
WHERE USERNAME = 'aaaaaa' -- userName
AND ROWNUM = 1;
IF isFound > 0 THEN
dbms_output.put_line('Found');
ELSE
dbms_output.put_line('Not found');
END IF;
end;