HomeОбразованиеRelated VideosMore From: Manish Sharma

PL/SQL tutorial 27: How To Create An Explicit Cursor In Oracle Database By Manish Sharma

545 ratings | 56464 views
Learn How To Create An Explicit Database Cursor In Oracle with easy to understand example by Manish Sharma RebellionRider.com ------------------------------------------------------------------------ ►►►LINKS◄◄◄ Blog : http://bit.ly/create-explicit-cursor Previous Tutorial ► Introduction To Database Cursor - https://youtu.be/_snAMqCBitg ► Simple Loop - https://youtu.be/AFx6QYcY1CU ------------------------------------------------------------------------- ►►►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 https://twitter.com/rebellionrider https://www.facebook.com/imthebhardwaj http://instagram.com/rebellionrider https://plus.google.com/+Rebellionrider http://in.linkedin.com/in/mannbhardwaj/ http://rebellionrider.tumblr.com/ http://www.pinterest.com/rebellionrider/ ___Facebook Official Page___ https://www.facebook.com/RebellionRider.official/ 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 This is Manish from RebellionRider.com ♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS
Html code for embedding videos on your blog
Text Comments (38)
Sinan Hos (6 days ago)
when I compile it, I always get the error message "RA-00942: table or view does not exist". How can I solve the error? "
Rafael Bicalho (5 months ago)
Thank you. Helped me a lot! :-)
Which editor you have used will you please say
Leonie Lausecker (5 months ago)
It is the SQL Developer
neha gaikwad (9 months ago)
Hello Sir, i have passed SQL 1z0-061 , now i want to appear for 1z0-062 for OCA and I was looking for your tutorials for that. But I couldnt find ay. Kindly help on how to learn it and from where(specifically online). Thank you
Edward G (1 year ago)
I'd do the line of EXIT WHEN then add the DBMS_OUTPUT.PUT_LINE to avoid repeating values for the last execution
Luis Fernando Guzman (8 months ago)
nice tip
Subhajit Karmakar (11 months ago)
absolutely..this is the right way to retrieve values.
Ming Yan (1 year ago)
For anyone with doubts why there is an extra row printed out at last. here is the answer: as mentioned in the video, curse_name%NOTFOUND returns false when the PREVIOUS FETCH returns a row. If false, after each fetch, SQL will give the value to the variable v_name , and then, print out the v_name; ........ when the cursor coming to the last tuple, fetch statement will give the last value to v_name; then print out v_name; Notice at this time, %NOTFOUND returns false because there is a row, the last row, so loop one more time. this time, fetch statement will not give anything to v_name, v_name stays the same as last time, which is the last row, then print out v_name AGAIN; this time, %NOTFOUND returns true, terminate the loop. to avoid this scenario, you can put exit when %notfound between fetch statement and print out, instead of putting it at last line. also you can use a while loop FETCH cursor_name into v_name; while cursor_name%NOTFOUND LOOP DBMS_OUTPUT.PUT_LINE(v_name); FETCH GET_CURSOR INTO v_name; end loop; close cursor_name; end;
pranay tanniru (1 month ago)
begin DBMS_OUTPUT.PUT_LINE('thank you so much for giving the solution to the problem'); end; /
hello mr.sharma love your channel helped me a lot in my studies i have a question. at 4:34 why Bruce is repeated ? i
Luis Fernando Guzman (8 months ago)
Check The ming answer. I have put the exit when before the DBMS_OUTPUT and the line is not repeated.
santhosh kotagiri (1 year ago)
The print output statement will be after the exit condition, otherwise the last row is duplicated.
Simmlex (1 year ago)
So... Why is this thing useful? You can achieve the same result with a simple 2 line SQL code.
Luis Fernando Guzman (8 months ago)
i guess because you can execute functions or another actions with the result of the cursor.
Pranav Srivastava (1 year ago)
Could you please explain why your output returned 'Bruce' twice in your result?
Hi, because the result statement on the screen is after the statement of the end of the cycle. Therefore, the cursor displays output 2 times.It is necessary to swap the 12 and 13 lines of code. First comes 13 line, and then 12.
Rahul Panda (2 years ago)
Hi Manish.....no doubt it is awesome....if you can also upload a video related to the use of cursor I. e. why when to use it and it's benefits...it would be wonderful.....thanks a lot.....it helps a lot....thanks again...
Stanislav Egevski (2 years ago)
i consider this like an array isn't?
uttam das (2 years ago)
Hi Manish, while i am trying to connect to the HR schema the below error is getting can you suggest me how to solve that? "Invalid connection operation operation specified and verify the URL format for the specified driver" Thanks Uttam
Amit Dey (2 years ago)
The print statement will be after the exit condition, else the last row is getting printed twice. :)
Pal Ayoub (2 years ago)
Amazing tuto! I think, the exiting statement is better to be placed right after the FETCH statement so the last output ligne doesn't get duplicated.
Syed Ahad (2 years ago)
Nice
Mohit Saxena (2 years ago)
sir why there are 2 bruce in the output?? the exit when statement should be written after the fetch statement..
santosh chary (2 years ago)
hello Manish...if you write an example code for user handling exception with a wonderful example like which you have given in other sessions then that is also very useful for many..... :)
madhu bhardwaj (2 years ago)
Sir, we can get the data in table by simply writing a select query then what is the advantage of creating cursor.
techprogrammer (2 years ago)
thank u so much for oracle tutorial video..................
Arun kumar Dachepalli (2 years ago)
Sir, we can get the data in table by simply writing a select querry that you wrote then what is the advantage of creating cursor.
Sameer D (1 year ago)
As Manish explained, even when you write a simple query, Implicit cursor is created. But you will not have control over that cursor. If we need to control the cursor (like storing values in variables and manipulating them in a complex manner, like using loops, IF ELSE conditions, etc.), then we can declare an explicit cursor.
Taiwo David Akinde (1 year ago)
Arun kumar Dachepalli Cursors becomes handy when you are dealing with records in the millions......look up Google for more information
nagaraj b (2 years ago)
Thanks for ur uploads expecting more videos on advanced topics like collections, bulk collect and PT.
pankaj pandey (2 years ago)
content and the way you present, both are awesome.
Kiran (2 years ago)
Hi Manish, Thanks for the video. Well I have one query, can you please tell me why is the Bruce record repeated twice ? In the Employee table, we have only one entry for bruce with id = 4. Thanks in Advance :)
Debajyoti Dutta (2 years ago)
I like your style of presentation. Very catchy. Thanks!
Manish Sharma (2 years ago)
Thank you so much for your wonderful comment. I am really grateful that you find my content entertaining. Please do make sure to Like and Share. Have a great day.
Asly Lee (2 years ago)
plz upload form and reports in oracle
Asly Lee (2 years ago)
yours tutorail is help me much more thanxxxxx so much
Manish Sharma (2 years ago)
+asly lee Thanks a lot for your appreciation. Always happy to help.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.