Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

issue on Parametrized cursors

Pierre Butera30 hours ago

I am refreshing my knowledge of PL/SQL and I am currently working on parametrized cursors. To make sure I understood the concept, I'm reproducing all straightforward examples I can find on Youtube. Unfortunately, NONE of them compiles, where as it does on the video. Can you please tell me what i'm doing wrong ?
example 1 is from https://www.youtube.com/watch?v=wQc8xBeLQ9I
The code is
>>>>>>
set serveroutput on;
declare
vt:=&choice number;
v1 varchar2(20);
cursor cur_emp(pjob varchar2) is select ename from emp where job=pjob;
begin
lf vt=1 then
vjob=:='CLERK'
elsif vt=2 then
vjob:='MANAGER'
else
vjob:=ANALYST'
end if;
open cur_emp(vjob);
loop
fetch cur_emp into v1;
exit when cur_emp%notfound;
dbms_output.put_line(v1);
end loop;
close cur_emp;
end;
>>>>>>>>>>>>
It is suppose to work on the "usual" scott/tiger scheme. SQL queries associated to the cursor are working fine, but PL/SQL block doesn't compile.
The error message is
>>>>>>>>>>>>
Error starting at line : 2 in command -

Error report -
ORA-06550: line 2, column 3:
PLS-00103: Encountered the symbol "=" when expecting one of the following:

constant exception <an identifier>
<a double-quoted delimited-identifier> table columns long
double ref char standard time timestamp interval date binary
national character nchar
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
>>>>>>>>>>>>
Please help on this one ! Thanks in advance

This post has been answered by Gerrit van der Linden on Oct 19 2025
Jump to Answer
Comments
Post Details
Added 30 hours ago
4 comments
69 views