PLS-00103 error while executing a sql block (Encountered the symbol "SELECT" ...)
PLS-00103 error while executing a sql block (Encountered the symbol "SELECT" ...)
我正在尝试学习 PLSQL,这是我一直在尝试执行的代码,当我执行代码时出现以下错误。
ORA-06550: line 2, column 7:
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
ORA-06550: line 2, column 58:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
* & - + ; / at for mod remainder rem <an exponent (**)> and
or group having intersect minus order start union where
connect || multiset
我知道你可以给select语句赋一个变量,然后在IF语句中使用那个变量,我只想知道下面代码中的错误。
BEGIN
IF((SELECT marks FROM students WHERE student_id ='s10')= 'Passed') THEN
DBMS_OUTPUT.PUT_LINE('Hello!');
END IF;
END;
begin
for i in (SELECT marks FROM students WHERE student_id ='s10') loop
if i.marks = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end loop;
end;
OR 如果 student_id 是唯一的
declare
v_mark students.marks%type;
begin
SELECT marks into v_mark FROM students WHERE student_id ='s10';
if v_mark = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end;
使用光标:
declare
cursor c1 is SELECT marks FROM students WHERE student_id ='s10';
begin
for r1 in c1 loop
if r1.marks = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end loop;
end;
我正在尝试学习 PLSQL,这是我一直在尝试执行的代码,当我执行代码时出现以下错误。
ORA-06550: line 2, column 7:
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
ORA-06550: line 2, column 58:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
* & - + ; / at for mod remainder rem <an exponent (**)> and
or group having intersect minus order start union where
connect || multiset
我知道你可以给select语句赋一个变量,然后在IF语句中使用那个变量,我只想知道下面代码中的错误。
BEGIN
IF((SELECT marks FROM students WHERE student_id ='s10')= 'Passed') THEN
DBMS_OUTPUT.PUT_LINE('Hello!');
END IF;
END;
begin
for i in (SELECT marks FROM students WHERE student_id ='s10') loop
if i.marks = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end loop;
end;
OR 如果 student_id 是唯一的
declare
v_mark students.marks%type;
begin
SELECT marks into v_mark FROM students WHERE student_id ='s10';
if v_mark = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end;
使用光标:
declare
cursor c1 is SELECT marks FROM students WHERE student_id ='s10';
begin
for r1 in c1 loop
if r1.marks = 'Passed' then
DBMS_OUTPUT.PUT_LINE('Hello!');
end if;
end loop;
end;