Reputation: 9032
I'm very new to PL/SQL programming. I have a table named course
. When I do:
select * from course where branchid = 'B1';
it returns the results as below:
And here is the PL/SQL programs I try to run against this table:
declare
v_branchId course.branchid%TYPE := 'B1';
cursor course_cur is
select * from course where branchid = v_branchId;
v_cursor course_cur%ROWTYPE;
BEGIN
open course_cur;
LOOP
FETCH course_cur into v_cursor;
exit when course_cur%NOTFOUND;
dbms_output.put_line('The course id is ' || v_cursor.courseid );
END LOOP;
END;
/
The program is been executed successfully, but it never prints the courseid
's at all, even though for branchid B1
I have several courseid
's.
Where I'm making the mistake?
Thanks in advance.
Upvotes: 0
Views: 689
Reputation: 470
can you please try this and let me know the result :)
declare
cursor course_cur (v_branchId in varchar2) is
select * from course where branchid = v_branchId;
v_cursor course_cur%ROWTYPE;
BEGIN
open course_cur ('B1');
LOOP
FETCH course_cur into v_cursor;
exit when course_cur%NOTFOUND;
dbms_output.put_line('The course id is ' || v_cursor.courseid );
END LOOP;
END;
thanks
Upvotes: 0
Reputation: 3499
set serveroutput on size unlimited
to get started. Check also wrapping option if needed.
http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#SQPUG099
Upvotes: 1