PL/SQL tutorial 36: Cursor Based Record Datatype variables part 2 By Manish Sharma

preview_player
Показать описание

------------------------------------------------------------------------
►►►LINKS◄◄◄
Previous Tutorial

-------------------------------------------------------------------------
►►►Let's Get Free Uber Cab◄◄◄
Use Referral Code UberRebellionRider and get $20 free for your first ride.

-------------------------------------------------------------------------
►Make sure you SUBSCRIBE and be the 1st one to see my videos!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
►►►Find me on Social Media◄◄◄
Follow What I am up to as it happens on

___Facebook Official Page___

You can also Email me at
for E-mail address please check About section

Please please LIKE and SHARE my videos it makes me happy.
Thanks for liking, commenting, sharing and watching more of our videos

♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS
Рекомендации по теме
Комментарии
Автор

--This is what you were telling us to answer Sir. Thank You so much. Now, it's very clear to me
declare
cursor mik is select * from employee;
begin
for var_emp in mik
loop
'||var_emp.Employee_no);
end loop;
end;
/

codestorywithMIK
Автор

When using cursors we don't need to declare and use rowtype variable, we can directly specify a rowtype variable corresponding to cursor in ' cursor for loop ' and access the data, like see the code that was in cursor for loop tutorial, the L_IDX used there is not at all declared but can be used to access tuples inside the cursor

prakash.r
Автор

Sir, we can achieve the same result by using cursor for loop. Here is the code
SET SERVEROUTPUT ON;
DECLARE
CURSOR CUR_RECORD IS
SELECT F_NAME, SALARY FROM STU WHERE CUS_ID<4;
V_REC CUR_RECORD%ROWTYPE;
BEGIN
FOR V_REC IN CUR_RECORD
LOOP
'||V_REC.SALARY);
END LOOP;
END;
/
Thank's sir...💜

almashossain
Автор

Not compiled the code but I believe we can achieve same result snippet below.

BEGIN

FOR cur_rr (SELECT first_name, salary FROM
employees where employee_id>200)
LOOP
|| cur_rr.salary);

END LOOP;
END;

himanshukp
Автор

Can you explain the usage of %rowtype with for loop cursor. Then how to fetch the cursor's data into the record.?

himanshumittal
Автор

I think we could do that without Loop as well ☺

muhamadabdulsamad
Автор

We can see the same result with for sir I have a question?
There is a variable which we declare to make cursor %Rowtype but I cannot use it bcoz of
FOR LOOP, when we declare for loop it have also a Rowtype Variable which we use in to DBMS_output.put_line.

talhagamingyt
Автор

declare
cursor c1 is select * from employees where department_id=20;
begin
for i in c1
loop



dbms_output.put_line('');
end loop;
end;
/

abhijeetpatil
Автор

It is necessary to close the cursor in cursor forloop

puneetbhardwaj
Автор

--Cursor Based Record Datatype Variable in Oracle Database with parameterized cursor and loop ( returning multiple rows ) - combined all the concepts for cursor and record type variable

declare
cursor cur_crv(v_dno number) is select ename, job, loc from emp join dept using(deptno) where
deptno<v_dno order by ename desc;
r_crv cur_crv%rowtype;
begin
open cur_crv(30);
loop
fetch cur_crv into r_crv;
exit when cur_crv%notfound;
'||r_crv.job||' '||r_crv.loc);
end loop;
close cur_crv;
end;
/

LazzyFrog
Автор

When I tried with for loop I'm getting error in PLSql developer. Error as 'Ora-01001:Invalid cursor'

MahadevPatil
Автор

You just need a loop to handle multiple rows returned from cursor, it's not very different from tut 35.
Great vids, but I feel some of your topics could have been covered together in a single video.
But I guess it's better for newbs this way, haha, great job

saby
Автор

We can use for loop to get the same result

set serveroutput on;
declare
cursor cur_emp is
select employee_id, first_name, last_name from employees where employee_id>200;
var_emp cur_emp%ROWTYPE;
begin
for v_emp in cur_emp
loop
||' '||v_emp.first_name||' '||v_emp.last_name);
exit when cur_emp%NOTFOUND;
end loop;
end;

AbhiNav-vxbb
Автор

@Manish, how can we fetch the data using cursor when we want to get the record by joining two or three tables.?

prabhatshrama
Автор

pls can you give me a oracle forms tuto

hanaeha